Project

General

Profile

Bug #17512 ยป 0001-Allow-ostruct-to-return-a-value-on-super.patch

ostruct super patch - HParker (Adam Hess), 01/05/2021 08:22 PM

View differences:

lib/ostruct.rb
raise! ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
end
set_ostruct_member_value!(mname, args[0])
elsif len == 0
elsif len == 0 # and /\A[a-z_]\w*\z/ =~ mid #
if @table.key?(mid)
new_ostruct_member!(mid) unless frozen?
@table[mid]
end
else
begin
super
test/ostruct/test_ostruct.rb
assert_equal(:bar, os.format)
end
def test_super
c = Class.new(OpenStruct) {
def foo; super; end
}
os = c.new(foo: :bar)
assert_equal(:bar, os.foo)
end
def test_overridden_public_methods
os = OpenStruct.new(method: :foo, class: :bar)
assert_equal(:foo, os.method)
    (1-1/1)