Sha256: 56709fe09b45b759f640daea6afde8f8505ff9bbc9a1a48720b47949e5f36adb

Contents?: true

Size: 618 Bytes

Versions: 3

Compression:

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

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_api_client-0.1.2 lib/json_api_client/query/base.rb
json_api_client-0.1.1 lib/json_api_client/query/base.rb
json_api_client-0.0.3 lib/json_api_client/query/base.rb