better documentation on how to use configure

This commit is contained in:
Konstantin Haase 2011-02-19 11:30:00 +01:00
parent ef54086552
commit 6136da5737
1 changed files with 26 additions and 1 deletions

View File

@ -922,7 +922,20 @@ The <tt>request.body</tt> is an IO or StringIO object:
Run once, at startup, in any environment:
configure do
...
# setting one option
set :option, 'value'
# setting multiple options
set :a => 1, :b => 2
# same as `set :option, true`
enable :option
# same as `set :option, false`
disable :option
# you can also have dynamic settings with blocks
set(:css_dir) { File.join(views, 'css') }
end
Run only when the environment (RACK_ENV environment variable) is set to
@ -939,6 +952,18 @@ Run when the environment is set to either <tt>:production</tt> or
...
end
You can access those options via <tt>settings</tt>:
configure do
set :foo, 'bar'
end
get '/' do
settings.foo? # => true
settings.foo # => 'bar'
...
end
== Error Handling
Error handlers run within the same context as routes and before filters, which