Class: JsonApiClient::Query::Base
- Inherits:
-
Object
- Object
- JsonApiClient::Query::Base
- Defined in:
- lib/json_api_client/query/base.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #build_params(args) ⇒ Object
-
#initialize(klass, args) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
Constructor Details
#initialize(klass, args) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/json_api_client/query/base.rb', line 7 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 |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/json_api_client/query/base.rb', line 5 def headers @headers end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/json_api_client/query/base.rb', line 5 def klass @klass end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/json_api_client/query/base.rb', line 5 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/json_api_client/query/base.rb', line 5 def path @path end |
Instance Method Details
#build_params(args) ⇒ Object
21 22 23 |
# File 'lib/json_api_client/query/base.rb', line 21 def build_params(args) @params = args.dup end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/json_api_client/query/base.rb', line 25 def inspect "method: #{request_method}; path: #{path}; params: #{params}, headers: #{headers}" end |