Sha256: b318bd1990026218cb45b6831c1a1a1694965fb5e907b33f25057e9e252a9885

Contents?: true

Size: 622 Bytes

Versions: 4

Compression:

Stored size: 622 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

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
json_api_client-0.2.2 lib/json_api_client/query/base.rb
json_api_client-0.2.1 lib/json_api_client/query/base.rb
json_api_client-0.2.0 lib/json_api_client/query/base.rb
json_api_client-0.1.3 lib/json_api_client/query/base.rb