summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2021-01-12 17:20:50 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2021-01-12 23:29:39 -0500
commitf48edc28dda3df962f289fd373c06a8dfeda3dc0 (patch)
tree2ea822f834a7e2cfa34d40bb3f33a135029f7420 /lib
parent75212f2fc6571bd9cab0381fbd0bde81e1b3159c (diff)
Fix method protection for modules in the ancestry chain.
[Fixes ruby/ostruct#23]
Diffstat (limited to 'lib')
-rw-r--r--lib/ostruct.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index e255a5e704..e00e281d6d 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -223,7 +223,15 @@ class OpenStruct
elsif name.end_with?('!')
true
else
- method!(name).owner < OpenStruct
+ owner = method!(name).owner
+ if owner.class == ::Class
+ owner < ::OpenStruct
+ else
+ self.class.ancestors.any? do |mod|
+ return false if mod == ::OpenStruct
+ mod == owner
+ end
+ end
end
end