Sha256: 1d946def891c175d04a98495c1267a61482b63fc57d841b62a26066292a78300

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 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
        self.connection_class = Connection
      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
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
json_api_client-0.2.4 lib/json_api_client/helpers/queryable.rb
json_api_client-0.2.3 lib/json_api_client/helpers/queryable.rb