From 17ffd28820e9decdbf6f53d89925c50acb4d5c06 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Tue, 5 Jan 2021 18:43:14 -0500 Subject: [PATCH 1/3] Typo fix --- test/ostruct/test_ostruct.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index fe001b2..d1a27f3 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -246,7 +246,7 @@ def test_overriden_private_methods assert_equal(:bar, os.format) end - def test_overriden_public_methods + def test_overridden_public_methods os = OpenStruct.new(method: :foo, class: :bar) assert_equal(:foo, os.method) assert_equal(:bar, os.class) From be721e9ebe3085ef95b675c532a56ffecd77a900 Mon Sep 17 00:00:00 2001 From: Adam Hess Date: Tue, 5 Jan 2021 15:34:45 -0800 Subject: [PATCH 2/3] Allow ostruct to return a value on super (#4028) This fixes cases where you can super in something that inherits from OpenStruct Co-authored-by: John Hawthorn --- lib/ostruct.rb | 1 + test/ostruct/test_ostruct.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 64b76da..c15ff8a 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -250,6 +250,7 @@ def freeze end set_ostruct_member_value!(mname, args[0]) elsif len == 0 + @table[mid] else begin super diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index d1a27f3..0a911ee 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -246,6 +246,14 @@ def test_overriden_private_methods 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) From 27d3b27a8ce4f305724eceb92478ade7db537574 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Tue, 5 Jan 2021 18:35:46 -0500 Subject: [PATCH 3/3] Bump version --- lib/ostruct.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index c15ff8a..505601b 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -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