Module: MR::Model::Persistence::InstanceMethods
- Defined in:
- lib/mr/model/persistence.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroyed? ⇒ Boolean
- #errors ⇒ Object
- #new? ⇒ Boolean
- #save ⇒ Object
- #transaction(&block) ⇒ Object
- #valid? ⇒ Boolean
Instance Method Details
#destroy ⇒ Object
37 38 39 |
# File 'lib/mr/model/persistence.rb', line 37 def destroy record.destroy end |
#destroyed? ⇒ Boolean
57 58 59 |
# File 'lib/mr/model/persistence.rb', line 57 def destroyed? record.destroyed? end |
#errors ⇒ Object
45 46 47 |
# File 'lib/mr/model/persistence.rb', line 45 def errors record.errors. end |
#new? ⇒ Boolean
53 54 55 |
# File 'lib/mr/model/persistence.rb', line 53 def new? record.new_record? end |
#save ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/mr/model/persistence.rb', line 28 def save self.transaction{ record.save! } rescue ActiveRecord::RecordInvalid => exception # `caller` is not consistent between 1.8 and 2.0, if we stop supporting # older versions, we can switch to using `caller` called_from = exception.backtrace[6..-1] raise InvalidError.new(self, self.errors, called_from) end |
#transaction(&block) ⇒ Object
41 42 43 |
# File 'lib/mr/model/persistence.rb', line 41 def transaction(&block) record.transaction(&block) end |
#valid? ⇒ Boolean
49 50 51 |
# File 'lib/mr/model/persistence.rb', line 49 def valid? record.valid? end |