I have the following function that works just fine
def holiday_hours_for(holiday)
hours["holiday_hours"][holiday.to_s] if hours["holiday_hours"][holiday.to_s]
end
I am just learning about virtual attributes, and am having some trouble figuring out the setter version of this function. How would I achieve this function...
def holiday_hours_for(holiday)=(hours)
self.hours["holiday_hours"][holiday.to_s] = hours if hours["holiday_hours"][holiday.to_s]
end
Thanks!
UPDATE: I came up with the following, is this the best way?
def update_holiday_hours_for(holiday, hours_text)
self.hours = Hash.new unless hours
self.hours["holiday_hours"] = Hash.new unless hours["holiday_hours"]
self.hours["holiday_hours"][holiday.to_s] = hours_text.to_s
end