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.
37 38 39 40 41 42 43 |
# File 'lib/gds_api/base.rb', line 37 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.
30 31 32 |
# File 'lib/gds_api/base.rb', line 30 def @default_options end |
.logger ⇒ Object
33 34 35 |
# File 'lib/gds_api/base.rb', line 33 def self.logger @logger ||= NullLogger.instance end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/gds_api/base.rb', line 26 def @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
12 13 14 |
# File 'lib/gds_api/base.rb', line 12 def client @client ||= create_client end |
#create_client ⇒ Object
16 17 18 |
# File 'lib/gds_api/base.rb', line 16 def create_client GdsApi::JsonClient.new() end |
#url_for_slug(slug, options = {}) ⇒ Object
49 50 51 |
# File 'lib/gds_api/base.rb', line 49 def url_for_slug(slug, ={}) base = "#{base_url}/#{slug}.json#{query_string()}" end |