I have a class like so:
class Item
attr_accessor :item_id, :name, :address, :description, :facilities, :ratings, :directions, :geo, :images, :video, :availability
def self.create options={}
item = Item.new
item.item_id = options[:item_id]
item.name = options[:name]
item.description = options[:desc]
item.ratings = options[:rating]
return item
end
end
How can I make the 'create' method in such a way as to read the given options that are getting passed and try to create them without having to specify their name explicitly?
ie. no item.name = options[:item_id] etc etc.... just... computer brain thinks "ah... i see the option 'option[:name], let me try to create an attribute with that same name and this value!..."