My problem is, I have a bunch of classes that extend Struct.new. And now I need add a common class method to all of them.
If Struct was a ‘normal’ superclass, I would be able to define a class method on it and then every subclass would also have that method.
Given, that it is not, how do I replicate this behaviour?
For example,
class Foo < Struct.new(:foo); end
Foo.respond_to?(:perform) #=> true
class Bar < Struct.new(:bar); end
Bar.respond_to?(:perform) #=> true
Why can’t you define a method on Struct?