Sha256: e45e7b3db557e0c91082e93e73357dc0798dd7413036f36d49a60cb9d0747c19

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module Restly::Base::Includes
  extend ActiveSupport::Concern

  module ClassMethods

    # Delegate stuff to client
    delegate :site, :site=, :format, :format=, to: :client

    def client
      @client ||= Restly::Client.new
    end

    def client=(client)
      raise Restly::Error::InvalidClient, "Client is invalid!"
      @client = client
    end

    def has_specification
      self.fields = Restly::Base::Resource::Specification.new(self).fields
      (self._accessible_attributes ||= {})[:default] = Restly::Base::Resource::Specification.new(self).accessible_attributes
    end

    def connection
      connection = @connection || Restly::Connection.tokenize(client, current_token)
      connection.cache ||= cache
      connection.cache_options = cache_options unless connection.cache_options.present?
      connection
    end

    def connection=(connection)
      raise InvalidConnection, "#{connection} is not a valid Restly::Connection" unless connection.is_a?(Restly::Connection)
      @connection = connection
    end

    def param_key
      resource_name
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
restly-0.0.1.alpha.11 lib/restly/base/includes.rb
restly-0.0.1.alpha.10 lib/restly/base/includes.rb