Module: Panda::Updatable

Included in:
Cloud, Profile
Defined in:
lib/panda/modules/updatable.rb

Instance Method Summary collapse

Instance Method Details

#saveObject



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

#updateObject



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