Class: GdsApi::Base
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/gds_api/base.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(platform, options_or_endpoint_url = nil, maybe_options = nil) ⇒ Base
Returns a new instance of Base.
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/gds_api/base.rb', line 33
def initialize(platform, options_or_endpoint_url=nil, maybe_options=nil)
if options_or_endpoint_url.is_a?(String)
options = maybe_options || {}
options[:endpoint_url] = options_or_endpoint_url
else
options = options_or_endpoint_url || {}
end
default_options = GdsApi::Base.default_options || {}
@options = default_options.merge(options)
self.endpoint = options[:endpoint_url] || endpoint_for_platform(adapter_name, platform)
end
|
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
26
27
28
|
# File 'lib/gds_api/base.rb', line 26
def default_options
@default_options
end
|
.logger ⇒ Object
29
30
31
|
# File 'lib/gds_api/base.rb', line 29
def self.logger
@logger ||= NullLogger.instance
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
22
23
24
|
# File 'lib/gds_api/base.rb', line 22
def options
@options
end
|
Instance Method Details
#adapter_name ⇒ Object
45
46
47
|
# File 'lib/gds_api/base.rb', line 45
def adapter_name
self.class.to_s.split("::").last.downcase
end
|
#client ⇒ Object
8
9
10
|
# File 'lib/gds_api/base.rb', line 8
def client
@client ||= create_client
end
|
#create_client ⇒ Object
12
13
14
|
# File 'lib/gds_api/base.rb', line 12
def create_client
GdsApi::JsonClient.new(options)
end
|
#url_for_slug(slug, options = {}) ⇒ Object
49
50
51
|
# File 'lib/gds_api/base.rb', line 49
def url_for_slug(slug, options={})
base = "#{base_url}/#{slug}.json#{query_string(options)}"
end
|