mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/ostruct] Fix class and method as attribute names
https://github.com/ruby/ostruct/commit/7258535073
This commit is contained in:
parent
1dd2d2ce48
commit
e1391bf96f
2 changed files with 7 additions and 1 deletions
|
@ -246,7 +246,7 @@ class OpenStruct
|
|||
if owner.class == ::Class
|
||||
owner < ::OpenStruct
|
||||
else
|
||||
self.class.ancestors.any? do |mod|
|
||||
self.class!.ancestors.any? do |mod|
|
||||
return false if mod == ::OpenStruct
|
||||
mod == owner
|
||||
end
|
||||
|
|
|
@ -406,4 +406,10 @@ class TC_OpenStruct < Test::Unit::TestCase
|
|||
o2 = Marshal.load(Marshal.dump(o))
|
||||
assert_equal o, o2
|
||||
end
|
||||
|
||||
def test_class
|
||||
os = OpenStruct.new(class: 'my-class', method: 'post')
|
||||
assert_equal('my-class', os.class)
|
||||
assert_equal(OpenStruct, os.class!)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue