mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
set can take a block in place of a Proc object
This commit is contained in:
parent
849a5a95fc
commit
15651d9ee1
1 changed files with 2 additions and 1 deletions
|
@ -679,7 +679,8 @@ module Sinatra
|
|||
|
||||
# Sets an option to the given value. If the value is a proc,
|
||||
# the proc will be called every time the option is accessed.
|
||||
def set(option, value=self)
|
||||
def set(option, value=self, &block)
|
||||
value = block if block
|
||||
if value.kind_of?(Proc)
|
||||
metadef(option, &value)
|
||||
metadef("#{option}?") { !!__send__(option) }
|
||||
|
|
Loading…
Add table
Reference in a new issue