From 15651d9ee14270048b511ab535287d3ddc965ad7 Mon Sep 17 00:00:00 2001 From: 7rans Date: Fri, 5 Feb 2010 12:48:54 -0500 Subject: [PATCH] set can take a block in place of a Proc object --- lib/sinatra/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index b9c1959d..bd9a4a51 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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) }