Sha256: 832e22fd1f7fbf5f5dcde021ed6b49eff498877b41f3010ade811c882422210a

Contents?: true

Size: 752 Bytes

Versions: 6

Compression:

Stored size: 752 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
      end

      module ClassMethods
        def new_scope
          Scope.new(self)
        end

        def connection
          @connection ||= begin
            super
          rescue
            build_connection
          end
          yield(@connection) if block_given?
          @connection
        end

        def build_connection
          connection_class.new(site)
        end

        def connection_class
          Connection
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
json_api_client-0.2.2 lib/json_api_client/helpers/queryable.rb
json_api_client-0.2.1 lib/json_api_client/helpers/queryable.rb
json_api_client-0.2.0 lib/json_api_client/helpers/queryable.rb
json_api_client-0.1.3 lib/json_api_client/helpers/queryable.rb
json_api_client-0.1.2 lib/json_api_client/helpers/queryable.rb
json_api_client-0.1.1 lib/json_api_client/helpers/queryable.rb