Sha256: 0c54cd0a874286c117fbf40c9047da3ef2e238b1782cb25865a7ad541fad42db
Contents?: true
Size: 1021 Bytes
Versions: 1
Compression:
Stored size: 1021 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 build_path(@params) end def build_path(parameters) @path = begin p = klass.path(parameters) if parameters.has_key?(klass.primary_key) && !parameters[klass.primary_key].is_a?(Array) resource_id = parameters.delete(klass.primary_key).to_s encoded_resource_id = Addressable::URI.encode_component(resource_id, Addressable::URI::CharacterClasses::UNRESERVED) p = File.join(p, encoded_resource_id) end p end end def build_params(args) @params = args.dup end def inspect "#{self.class.name}: method: #{request_method}; path: #{path}; params: #{params}, headers: #{headers}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json_api_client-0.8.0 | lib/json_api_client/query/base.rb |