Module: CleanModel::Persistent::InstanceMethods
- Defined in:
- lib/clean_model/persistent.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
- #save ⇒ Object
- #save! ⇒ Object
- #update_attributes(attributes) ⇒ Object
Instance Method Details
#destroy ⇒ Object
55 56 57 |
# File 'lib/clean_model/persistent.rb', line 55 def destroy delete end |
#new_record? ⇒ Boolean
33 34 35 |
# File 'lib/clean_model/persistent.rb', line 33 def new_record? id.nil? end |
#persisted? ⇒ Boolean
37 38 39 |
# File 'lib/clean_model/persistent.rb', line 37 def persisted? !new_record? end |
#save ⇒ Object
45 46 47 48 |
# File 'lib/clean_model/persistent.rb', line 45 def save return false unless valid? new_record? ? create : update end |
#save! ⇒ Object
41 42 43 |
# File 'lib/clean_model/persistent.rb', line 41 def save! raise errors..join("\n") unless save end |
#update_attributes(attributes) ⇒ Object
50 51 52 53 |
# File 'lib/clean_model/persistent.rb', line 50 def update_attributes(attributes) assign_attributes attributes save end |