Class: ActiveRecord::Base::VeneerInterface::InstanceWrapper

Inherits:
Veneer::Base::InstanceWrapper show all
Defined in:
lib/veneer/adapters/activerecord/instance_wrapper.rb

Instance Attribute Summary

Attributes inherited from Veneer::Base::InstanceWrapper

#instance, #options

Instance Method Summary collapse

Methods inherited from Veneer::Base::InstanceWrapper

#==, #class, #handle_before_save_error, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Veneer::Base::InstanceWrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Veneer::Base::InstanceWrapper

Instance Method Details

#saveObject



17
18
19
20
21
# File 'lib/veneer/adapters/activerecord/instance_wrapper.rb', line 17

def save
  instance.save
rescue Veneer::Errors::BeforeSaveError => e
  handle_before_save_error(e)
end

#save!Object



11
12
13
14
15
# File 'lib/veneer/adapters/activerecord/instance_wrapper.rb', line 11

def save!
  instance.save!
rescue ActiveRecord::RecordInvalid, Veneer::Errors::BeforeSaveError=> e
  raise ::Veneer::Errors::NotSaved, e.message
end

#update(attributes = {}) ⇒ Object



5
6
7
8
9
# File 'lib/veneer/adapters/activerecord/instance_wrapper.rb', line 5

def update(attributes = {})
  instance.update_attributes(attributes)
rescue Veneer::Errors::BeforeSaveError => e
  handle_before_save_error(e)
end