Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from main repo #21

Merged
merged 3 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ostruct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
# For all these reasons, consider not using OpenStruct at all.
#
class OpenStruct
VERSION = "0.3.1"
VERSION = "0.3.2"

#
# Creates a new OpenStruct object. By default, the resulting OpenStruct
Expand Down Expand Up @@ -250,6 +250,7 @@ def freeze
end
set_ostruct_member_value!(mname, args[0])
elsif len == 0
@table[mid]
else
begin
super
Expand Down
10 changes: 9 additions & 1 deletion test/ostruct/test_ostruct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,15 @@ def test_overriden_private_methods
assert_equal(:bar, os.format)
end

def test_overriden_public_methods
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)
assert_equal(:bar, os.class)
Expand Down