Sha256: 9073a3c812c26d828c155394d5cd575dfa5bd257472ff0186b825f754f38bda4

Contents?: true

Size: 741 Bytes

Versions: 8

Compression:

Stored size: 741 Bytes

Contents

module Restly::Base::Instance::Actions

  def save
    run_callbacks :save do
      @previously_changed = changes
      @changed_attributes.clear
      new_record? ? create : update
    end
    self
  end

  def delete
    response = connection.delete(path_with_format, params: params)
    freeze
    response.status < 300
  end

  def destroy
    run_callbacks :destroy do
      delete
    end
  end

  private

  def update
    run_callbacks :update do
      set_attributes_from_response(connection.put path_with_format, body: @request_body, params: params)
    end
  end

  def create
    run_callbacks :create do
      set_attributes_from_response(connection.post path_with_format, body: @request_body, params: params)
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
restly-0.0.1.alpha.16 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.12 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.11 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.10 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.9 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.8 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.7 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.6 lib/restly/base/instance/actions.rb