Module: Panda::Updatable
Instance Method Summary collapse
- #save ⇒ Object
- #save! ⇒ Object
- #update ⇒ Object
- #update_attribute(name, value) ⇒ Object
- #update_attributes(attributes) ⇒ Object
Instance Method Details
#save ⇒ Object
4 5 6 |
# File 'lib/panda/modules/updatable.rb', line 4 def save new? ? create : update end |
#save! ⇒ Object
8 9 10 |
# File 'lib/panda/modules/updatable.rb', line 8 def save! save || raise("Resource invalid") end |
#update ⇒ Object
21 22 23 24 |
# File 'lib/panda/modules/updatable.rb', line 21 def update response = connection.put(object_url_map(self.class.one_path), @changed_attributes) load_response(response) ? (@changed_attributes = {}; true) : false end |
#update_attribute(name, value) ⇒ Object
12 13 14 15 |
# File 'lib/panda/modules/updatable.rb', line 12 def update_attribute(name, value) self.send("#{name}=".to_sym, value) self.save end |
#update_attributes(attributes) ⇒ Object
17 18 19 |
# File 'lib/panda/modules/updatable.rb', line 17 def update_attributes(attributes) load(attributes) && save end |