by celdon25 · 1y ago · 0 comments
The idea of distinct “concrete” and “dynamic” classes seems to be a product of a wrong mental model of how Ruby is executed.
There is no effectively no difference between these:
class Foo < Bar
attr_accessor :baz
end
Foo = Class.new(Bar) do
define_method(:baz) do
@baz
end
endAlso, if you’re writing a custom data class, you’d need to write code to support immutability which this article’s approach handles