This project is closed and read-only.
Backport #6063 ยป openstruct-delete-field-fix.patch
| lib/ostruct.rb (working copy) | ||
|---|---|---|
|
#
|
||
|
def delete_field(name)
|
||
|
sym = name.to_sym
|
||
|
singleton_class.__send__(:remove_method, sym, "#{name}=")
|
||
|
@table.delete sym
|
||
|
singleton_class.__send__(:remove_method, sym, "#{name}=")
|
||
|
end
|
||
|
InspectKey = :__inspect_key__ # :nodoc:
|
||
| test/ostruct/test_ostruct.rb (working copy) | ||
|---|---|---|
|
o.a = 'a'
|
||
|
assert_respond_to(o, :a)
|
||
|
assert_respond_to(o, :a=)
|
||
|
o.delete_field :a
|
||
|
a = o.delete_field :a
|
||
|
assert_not_respond_to(o, :a, bug)
|
||
|
assert_not_respond_to(o, :a=, bug)
|
||
|
assert_equal(a, 'a')
|
||
|
end
|
||
|
def test_method_missing_handles_square_bracket_equals
|
||