Sha256: 890f33037be1201f23d26989f52da80f8183a3d378ccb7486ff536894152ff7d

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

module Restly::Base::Resource::Finders

  Collection = Restly::Collection

  def find(id, *args)
    options = args.extract_options!

    #params[pagination_options[:params][:page]] = options[:page] if pagination
    instance_from_response connection.get(path_with_format(id), params: params)
  end

  def all
    collection_from_response connection.get(path_with_format, params: params)
  end

  def create(attributes = nil, options = {})
    instance = self.new(attributes, options)
    instance.save
  end

  def collection_from_response(response)
    raise Restly::Error::InvalidResponse unless response.is_a? OAuth2::Response
    Collection.new resource, nil, response: response
  end

  def instance_from_response(response)
    new(nil, response: response, connection: connection)
  end

  alias_method :from_response, :instance_from_response

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restly-0.0.1.beta.3 lib/restly/base/resource/finders.rb