better documentation on how to use configure
This commit is contained in:
parent
ef54086552
commit
6136da5737
27
README.rdoc
27
README.rdoc
|
@ -922,7 +922,20 @@ The <tt>request.body</tt> is an IO or StringIO object:
|
||||||
Run once, at startup, in any environment:
|
Run once, at startup, in any environment:
|
||||||
|
|
||||||
configure do
|
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
|
end
|
||||||
|
|
||||||
Run only when the environment (RACK_ENV environment variable) is set to
|
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
|
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 Handling
|
||||||
|
|
||||||
Error handlers run within the same context as routes and before filters, which
|
Error handlers run within the same context as routes and before filters, which
|
||||||
|
|
Loading…
Reference in New Issue