* lib/ostruct.rb: Have OpenStruct#dig raise if argument is not a symbol
nor a string. See [#11762] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
96c4fa0b09
commit
13d8bb0385
@ -1,3 +1,9 @@
|
|||||||
|
Sun Dec 13 06:40:30 2015 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
|
* lib/ostruct.rb: Have OpenStruct#dig raise if argument is not a
|
||||||
|
symbol
|
||||||
|
nor a string. See [#11762]
|
||||||
|
|
||||||
Sun Dec 13 00:05:42 2015 Shugo Maeda <shugo@ruby-lang.org>
|
Sun Dec 13 00:05:42 2015 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_call_method_missing): method_missing should
|
* vm_insnhelper.c (vm_call_method_missing): method_missing should
|
||||||
|
@ -227,7 +227,7 @@ class OpenStruct
|
|||||||
begin
|
begin
|
||||||
name = name.to_sym
|
name = name.to_sym
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
return
|
raise TypeError, "#{name} is not a symbol nor a string"
|
||||||
end
|
end
|
||||||
@table.dig(name, *names)
|
@table.dig(name, *names)
|
||||||
end
|
end
|
||||||
|
@ -116,7 +116,7 @@ class TC_OpenStruct < Test::Unit::TestCase
|
|||||||
os2.child = [42]
|
os2.child = [42]
|
||||||
assert_equal :bar, os1.dig("child", :foo)
|
assert_equal :bar, os1.dig("child", :foo)
|
||||||
assert_nil os1.dig("parent", :foo)
|
assert_nil os1.dig("parent", :foo)
|
||||||
assert_nil os1.dig("child", 0)
|
assert_raise(TypeError) { os1.dig("child", 0) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_h
|
def test_to_h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user