Y
Yossef Mendelssohn
Is it possible to modify the members of a Struct class once it's been
created, yet retain all other behavior?
An example:
Thing = Struct.newa, :b, :c) do
def some_method
end
end
Is there a way to modify Thing so it behaves as if it were effectively
created like so?
Thing = Struct.newa, :b, :c, :d) do
def some_method
end
end
Re-assigning Thing to a new Struct obviously doesn't work because then
the behavior is lost.
Altering Thing.members seemed promising, but that didn't work either.
Adding attr_accessor for :d isn't good because I need Thing.new['d']
to work.
Thoughts?
created, yet retain all other behavior?
An example:
Thing = Struct.newa, :b, :c) do
def some_method
end
end
Is there a way to modify Thing so it behaves as if it were effectively
created like so?
Thing = Struct.newa, :b, :c, :d) do
def some_method
end
end
Re-assigning Thing to a new Struct obviously doesn't work because then
the behavior is lost.
Altering Thing.members seemed promising, but that didn't work either.
Adding attr_accessor for :d isn't good because I need Thing.new['d']
to work.
Thoughts?