Module: ActiveRecordExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_record_extension.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #delete ⇒ Object
- #destroy ⇒ Object
- #destroy! ⇒ Object
- #save ⇒ Object
- #save! ⇒ Object
- #update(attributes) ⇒ Object
- #update_attribute(name, value) ⇒ Object
Instance Method Details
#delete ⇒ Object
7 8 9 |
# File 'lib/active_record_extension.rb', line 7 def delete ::OData::Model.destroy(self) end |
#destroy ⇒ Object
11 12 13 14 15 |
# File 'lib/active_record_extension.rb', line 11 def destroy destroy! rescue false end |
#destroy! ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record_extension.rb', line 17 def destroy! run_callbacks :destroy do ::OData::Model.destroy(self) end has_errors = errors.present? if has_errors raise_record_not_destroyed end !has_errors end |
#save ⇒ Object
28 29 30 31 32 |
# File 'lib/active_record_extension.rb', line 28 def save(*) save! rescue false end |
#save! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_record_extension.rb', line 34 def save!(*) validate! run_callbacks :save do ::OData::Model.save(self) end has_errors = errors.present? if has_errors raise_record_invalid else reload end !has_errors end |
#update(attributes) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/active_record_extension.rb', line 48 def update(attributes) attributes.each do |k,v| write_attribute(k,v) end save end |
#update_attribute(name, value) ⇒ Object
55 56 57 58 |
# File 'lib/active_record_extension.rb', line 55 def update_attribute(name, value) write_attribute(name,value) save end |