mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
better documentation on how to use configure
This commit is contained in:
parent
ef54086552
commit
6136da5737
1 changed files with 26 additions and 1 deletions
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:
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue