mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
parent
df9b786e59
commit
1187a86634
2 changed files with 7 additions and 2 deletions
|
@ -704,8 +704,8 @@ module Sinatra
|
|||
metadef(option, &value)
|
||||
metadef("#{option}?") { !!__send__(option) }
|
||||
metadef("#{option}=") { |val| metadef(option, &Proc.new{val}) }
|
||||
elsif value == self && option.respond_to?(:to_hash)
|
||||
option.to_hash.each { |k,v| set(k, v) }
|
||||
elsif value == self && option.respond_to?(:each)
|
||||
option.each { |k,v| set(k, v) }
|
||||
elsif respond_to?("#{option}=")
|
||||
__send__ "#{option}=", value
|
||||
else
|
||||
|
|
|
@ -43,6 +43,11 @@ class SettingsTest < Test::Unit::TestCase
|
|||
assert_equal 'bizzle', @base.baz
|
||||
end
|
||||
|
||||
it 'sets multiple settings using #each' do
|
||||
@base.set [["foo", "bar"]]
|
||||
assert_equal "bar", @base.foo
|
||||
end
|
||||
|
||||
it 'inherits settings methods when subclassed' do
|
||||
@base.set :foo, 'bar'
|
||||
@base.set :biz, Proc.new { 'baz' }
|
||||
|
|
Loading…
Reference in a new issue