File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -453,7 +453,12 @@ def init_with(coder) # :nodoc:
453453 end
454454
455455 # Make all public methods (builtin or our own) accessible with <code>!</code>:
456- instance_methods . each do |method |
456+ give_access = instance_methods
457+ # See https://github.com/ruby/ostruct/issues/30
458+ give_access -= %i[ instance_exec instance_eval eval ] if RUBY_ENGINE == 'jruby'
459+ give_access . each do |method |
460+ next if method . match ( /\W $/ )
461+
457462 new_name = "#{ method } !"
458463 alias_method new_name , method
459464 end
Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ def test_access_original_methods
280280 os = OpenStruct . new ( method : :foo , hash : 42 )
281281 assert_equal ( os . object_id , os . method! ( :object_id ) . call )
282282 assert_not_equal ( 42 , os . hash! )
283+ refute os . methods . include? ( :"!~!" )
283284 end
284285
285286 def test_override_subclass
You can’t perform that action at this time.
0 commit comments