Skip to content

Commit

Permalink
Redefine Struct.new(...).new
Browse files Browse the repository at this point in the history
This should not reuse Struct.new, but fall back to the original
constructor instead.
  • Loading branch information
herwinw committed Dec 16, 2024
1 parent f2460b2 commit 568d80c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def self.new(*attrs, &block)
Struct.const_set(klass, result)
end

def result.new(...)
Object.method(:new).unbind.bind(self).call(...)
end

result
end
end
Expand Down

0 comments on commit 568d80c

Please sign in to comment.