From 6136da57374520d524bc1d6b43fe17e3ea81ea05 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sat, 19 Feb 2011 11:30:00 +0100 Subject: [PATCH] better documentation on how to use configure --- README.rdoc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 05e49d28..49c4c34f 100644 --- a/README.rdoc +++ b/README.rdoc @@ -922,7 +922,20 @@ The request.body 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 :production or ... end +You can access those options via settings: + + 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