1
0
Fork 0
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:
7rans 2010-02-05 12:48:54 -05:00
parent 849a5a95fc
commit 15651d9ee1

View file

@ -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) }