Class: GdsApi::Base
- Inherits:
-
Object
- Object
- GdsApi::Base
- Extended by:
- Forwardable
- Defined in:
- lib/gds_api/base.rb
Direct Known Subclasses
ContentApi, Imminence, LicenceApplication, Needotron, Panopticon, Publisher
Defined Under Namespace
Classes: InvalidAPIURL
Class Attribute Summary collapse
-
.default_options ⇒ Object
Returns the value of attribute default_options.
- .logger ⇒ Object
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #adapter_name ⇒ Object
- #client ⇒ Object
- #create_client ⇒ Object
-
#initialize(endpoint_url, options = {}) ⇒ Base
constructor
A new instance of Base.
- #url_for_slug(slug, options = {}) ⇒ Object
Constructor Details
#initialize(endpoint_url, options = {}) ⇒ Base
Returns a new instance of Base.
36 37 38 39 40 41 42 |
# File 'lib/gds_api/base.rb', line 36 def initialize(endpoint_url, ={}) [:endpoint_url] = endpoint_url raise InvalidAPIURL unless endpoint_url =~ URI::regexp = GdsApi::Base. || {} @options = .merge() self.endpoint = [:endpoint_url] end |
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
29 30 31 |
# File 'lib/gds_api/base.rb', line 29 def @default_options end |
.logger ⇒ Object
32 33 34 |
# File 'lib/gds_api/base.rb', line 32 def self.logger @logger ||= NullLogger.instance end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/gds_api/base.rb', line 25 def @options end |
Instance Method Details
#adapter_name ⇒ Object
44 45 46 |
# File 'lib/gds_api/base.rb', line 44 def adapter_name self.class.to_s.split("::").last.downcase end |
#client ⇒ Object
11 12 13 |
# File 'lib/gds_api/base.rb', line 11 def client @client ||= create_client end |
#create_client ⇒ Object
15 16 17 |
# File 'lib/gds_api/base.rb', line 15 def create_client GdsApi::JsonClient.new() end |
#url_for_slug(slug, options = {}) ⇒ Object
48 49 50 |
# File 'lib/gds_api/base.rb', line 48 def url_for_slug(slug, ={}) base = "#{base_url}/#{slug}.json#{query_string()}" end |