Sha256: 26064600486d693a2d4b561522a3e5a8227164ef2e04bce9096a4fa5c45de5d1

Contents?: true

Size: 936 Bytes

Versions: 16

Compression:

Stored size: 936 Bytes

Contents

module JsonApiClient
  module Helpers
    module Queryable
      extend ActiveSupport::Concern

      included do
        class << self
          extend Forwardable
          def_delegators :new_scope, :where, :order, :includes, :all, :paginate, :page, :first
        end
        class_attribute :connection_class, :connection_object, :connection_options
        self.connection_class = Connection
        self.connection_options = {}
      end

      module ClassMethods
        def new_scope
          Scope.new(self)
        end

        def connection(&block)
          build_connection(&block)
          connection_object
        end

        def build_connection
          return connection_object unless connection_object.nil?
          self.connection_object = connection_class.new(connection_options.merge(site: site)).tap do |conn|
            yield(conn) if block_given?
          end
        end
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
json_api_client-0.9.6 lib/json_api_client/helpers/queryable.rb
json_api_client-0.9.5 lib/json_api_client/helpers/queryable.rb
json_api_client-0.9.4 lib/json_api_client/helpers/queryable.rb
json_api_client-0.9.3 lib/json_api_client/helpers/queryable.rb
json_api_client-0.9.2 lib/json_api_client/helpers/queryable.rb
json_api_client-0.9.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.8.1 lib/json_api_client/helpers/queryable.rb
json_api_client-0.8.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.7.1 lib/json_api_client/helpers/queryable.rb
json_api_client-0.7.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.6.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.5.1 lib/json_api_client/helpers/queryable.rb
json_api_client-0.5.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.4.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.3.1 lib/json_api_client/helpers/queryable.rb
json_api_client-0.3.0 lib/json_api_client/helpers/queryable.rb