I have this class:
class PriceChange
attr_accessor :distributor_id, :product_id, :value, :price_changed_at, :realm
def initialize(data = {})
@distributor_id = data[:distributor_id]
@product_id = data[:product_id]
@value = data[:value]
@price_changed_at = data[:price_changed_at]
@realm = data[:realm]
end
end
And I want to avoid the mapping inside the method body.
I want a transparent and elegant way to set the instance attributes values.
I know I can iterate through the data keys and use something like define_method
. I don't want this. I want to do this in a clean way.