Class: ApiClient::Base
Instance Attribute Summary
#default_scopes
#connection_hooks
Class Method Summary
collapse
Instance Method Summary
collapse
inherited
build, build_many, build_one, extended
always, scope, scope_in_thread, scope_thread_attribute_name, scoped
connection
delegate
dsl_accessor
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &blk) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/api_client/base.rb', line 57
def method_missing(method_name, *args, &blk)
if respond_to?(method_name) || has_special_ending?(method_name)
super
elsif use_strict_reader?(method_name)
fetch(method_name)
else
super
end
end
|
Class Method Details
.parse(response) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/api_client/base.rb', line 22
def parse(response)
if response.is_a?(Faraday::Response)
return nil if response.status == 204
response = response.body
end
if self.format == :json
MultiJson.load(response)
elsif self.format == :xml
MultiXml.parse(response)
else
response
end
end
|
.subkey_class ⇒ Object
18
19
20
|
# File 'lib/api_client/base.rb', line 18
def subkey_class
Hashie::Mash
end
|
Instance Method Details
#id ⇒ Object
42
43
44
|
# File 'lib/api_client/base.rb', line 42
def id
self['id']
end
|
#inspect ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/api_client/base.rb', line 46
def inspect
attributes = []
attr_keys = self.keys - ['id']
attributes.push "id: #{self.id}" if self.id
attr_keys.each do |key|
attributes.push("#{key}: #{self[key].inspect}")
end
"#<#{self.class} #{attributes.join(', ')}>"
end
|