class Sinatra::Base
def set(option, value=self, &block)
Sets an option to the given value. If the value is a proc,
def set(option, value=self, &block) raise ArgumentError if block && value != self value = block if block if value.kind_of?(Proc) metadef(option, &value) metadef("#{option}?") { !!__send__(option) } metadef("#{option}=") { |val| metadef(option, &Proc.new{val}) } elsif value == self && option.respond_to?(:each) option.each { |k,v| set(k, v) } elsif respond_to?("#{option}=") __send__ "#{option}=", value else set option, Proc.new{value} end self end