Sha256: 2a041026965488d2dda5c1c7be40ab87da045887e12b52c9a5855b5f7703dc0f

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 Bytes

Contents

module Panda
  module Updatable

    def save
      new? ? create : update
    end

    def save!
      save || raise("Resource invalid")
    end

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

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

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
panda-1.4.1 lib/panda/modules/updatable.rb
panda-1.4.0 lib/panda/modules/updatable.rb