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(errors.last)
end

#updateObject



24
25
26
27
28
# File 'lib/panda/modules/updatable.rb', line 24

def update
  uri = replace_pattern_with_self_variables(self.class.one_path)
  response = connection.put(uri, @changed_attributes)
  load_and_reset(response)
end

#update_attribute(name, value) ⇒ Object



12
13
14
# File 'lib/panda/modules/updatable.rb', line 12

def update_attribute(name, value)
  send("#{name}=".to_sym, value) && save
end

#update_attributes(attributes) ⇒ Object



16
17
18
# File 'lib/panda/modules/updatable.rb', line 16

def update_attributes(attributes)
  load(attributes) && save
end

#update_attributes!(attributes) ⇒ Object



20
21
22
# File 'lib/panda/modules/updatable.rb', line 20

def update_attributes!(attributes)
  update_attributes(attributes) || raise(errors.last)
end