Sha256: c24cca4804b3307e768155eaa9bf180e855390b06488934713e179c87564a2ff

Contents?: true

Size: 742 Bytes

Versions: 7

Compression:

Stored size: 742 Bytes

Contents

module JsonApiClient
  module Query
    class Base
      class_attribute :request_method
      attr_reader :klass, :headers, :path, :params

      def initialize(klass, args)
        @klass = klass
        build_params(args)
        @headers = klass.default_headers.dup

        @path = begin
          p = klass.path(@params)
          if @params.has_key?(klass.primary_key) && !@params[klass.primary_key].is_a?(Array)
            p = File.join(p, @params.delete(klass.primary_key).to_s)
          end
          p
        end
      end

      def build_params(args)
        @params = args.dup
      end

      def inspect
        "method: #{request_method}; path: #{path}; params: #{params}, headers: #{headers}"
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
json_api_client-0.5.1 lib/json_api_client/query/base.rb
json_api_client-0.5.0 lib/json_api_client/query/base.rb
json_api_client-0.4.0 lib/json_api_client/query/base.rb
json_api_client-0.3.1 lib/json_api_client/query/base.rb
json_api_client-0.3.0 lib/json_api_client/query/base.rb
json_api_client-0.2.4 lib/json_api_client/query/base.rb
json_api_client-0.2.3 lib/json_api_client/query/base.rb