RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: basvanwesting
I have had the same issue with equality. I ended up letting Struct solve the equality issues for me. This preserves equality for usage with arrays, hash (keys), sets etc..
The example below decorates ServiceType with start_date & end_date from another model:
ServiceTypeWithDates = Struct.new(:service_type) do
def initialize(service_type, thing_with_start_and_end_date)
self.thing_with_start_and_end_date = thing_with_start_and_end_date
delegate :start_date, :end_date, :to => :thing_with_start_and_end_date
delegate *ServiceType.column_names, :to => :service_type