Sha256: c3e96af63e242f4bfa66d4a8412f6fda2e22f661e3a77d802161cfb38d508877

Contents?: true

Size: 709 Bytes

Versions: 6

Compression:

Stored size: 709 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_response(connection.put path_with_format, body: @request_body, params: params)
    end
  end

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
restly-0.0.1.beta.3 lib/restly/base/instance/actions.rb
restly-0.0.1.beta.2 lib/restly/base/instance/actions.rb
restly-0.0.1.beta.1 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.22 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.19 lib/restly/base/instance/actions.rb
restly-0.0.1.alpha.18 lib/restly/base/instance/actions.rb