I will read informations from a file and create an object.
During my load I do not know if it is a employe or a customer so I
create a person object.
After the object is created I will know which type it is.
After I know I want to change the type of my object.
“Type”? What exactly do you mean by ‘type’?
If you mean class, you can do this (untested in irb)
def self.new( param, data )
Now Person.new(param, data) will return an Employee or a Customer
on the param it is passed. Adjust as needed in terms of inspecting the
I consider this needless trickery, but have used it before because it
me. The other responses have more actual software engineering merit.