Class: UnsavedObject
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- UnsavedObject
- Defined in:
- lib/generators/not_yet_active_record/templates/unsaved_object.rb
Instance Method Summary collapse
Instance Method Details
#item ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/not_yet_active_record/templates/unsaved_object.rb', line 4 def item return nil if not serialized_item att_hash = YAML::load(serialized_item) att_hash.delete("id") att_hash.delete("created_at") att_hash.delete("updated_at") item_obj = model_name.constantize.new att_hash.each do |key, value| sym = (key + "=").to_sym item_obj.send(sym, value) end item_obj end |