Sha256: 3ae8efef7ab44fef84549e7a4715c4c6290d35c8735417595524fcb3f7e6b603

Contents?: true

Size: 826 Bytes

Versions: 13

Compression:

Stored size: 826 Bytes

Contents

module Restly::Base::Resource::Finders

  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
    Restly::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

13 entries across 13 versions & 1 rubygems

Version Path
restly-0.0.1.beta.2 lib/restly/base/resource/finders.rb
restly-0.0.1.beta.1 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.22 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.19 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.18 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.16 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.12 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.11 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.10 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.9 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.8 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.7 lib/restly/base/resource/finders.rb
restly-0.0.1.alpha.6 lib/restly/base/resource/finders.rb