File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -356,14 +356,14 @@ def dig(name, *names)
356
356
#
357
357
# person.delete_field('number') { 8675_309 } # => 8675309
358
358
#
359
- def delete_field ( name )
359
+ def delete_field ( name , & block )
360
360
sym = name . to_sym
361
361
begin
362
362
singleton_class . remove_method ( sym , "#{ sym } =" )
363
363
rescue NameError
364
364
end
365
365
@table . delete ( sym ) do
366
- return yield if block_given!
366
+ return yield if block
367
367
raise! NameError . new ( "no field `#{ sym } ' in #{ self } " , sym )
368
368
end
369
369
end
@@ -467,6 +467,11 @@ def init_with(coder) # :nodoc:
467
467
end
468
468
# Other builtin private methods we use:
469
469
alias_method :raise! , :raise
470
- alias_method :block_given! , :block_given?
471
- private :raise! , :block_given!
470
+ private :raise!
471
+
472
+ # See https://github.com/ruby/ostruct/issues/40
473
+ if RUBY_ENGINE != 'jruby'
474
+ alias_method :block_given! , :block_given?
475
+ private :block_given!
476
+ end
472
477
end
You can’t perform that action at this time.
0 commit comments