Module: MotionDataWrapper::Model::Persistence::ClassMethods
- Defined in:
- lib/motion_data_wrapper/model/persistence.rb
Instance Method Summary collapse
Instance Method Details
#create(attributes = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/motion_data_wrapper/model/persistence.rb', line 11 def create(attributes={}) begin model = create!(attributes) rescue MotionDataWrapper::RecordNotSaved end model end |
#create!(attributes = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/motion_data_wrapper/model/persistence.rb', line 19 def create!(attributes={}) model = new(attributes) model.save! model end |
#new(attributes = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/motion_data_wrapper/model/persistence.rb', line 25 def new(attributes={}) alloc.initWithEntity(entity_description, insertIntoManagedObjectContext:nil).tap do |model| model.instance_variable_set('@new_record', true) attributes.each do |keyPath, value| model.setValue(value, forKey:keyPath) end end end |