Sinatra (Sinatra :: Configfile 사용)에서 간단한 설정을 얻는 것은 settings.foo
과 같이 매우 쉽습니다. 그러나 설정을 계층 구조에 넣어야하는 경우 완전히 수행하는 방법이 명확하지 않습니다 간단하고 직접적인 방법으로 이 가까이동적으로 Sinatra에서 중첩 된 설정 가져 오기
get '/test' do
case settings.environment
when :production
settings.production['foo']
else
settings.development['foo']
end
end
뭔가 훨씬 더 좋을 것이다, 그러나 이것은 작동하지 않습니다 :
이 고통스럽게 장황
get '/test' do
settings[settings.environment]['foo']
end
'settings.send (settings.environment) [ 'foo']'는 어떻습니까? –
그래, 그런 식으로 생각했는데, 더 표준적인 (단순하고 우아한/읽을 수있는) Sinatra 방법을 가정하고있다. – iconoclast