Class: Ecfr::Base
- Extended by:
- Extensible
- Includes:
- AttributeMethodDefinition, Enumerable
- Defined in:
- lib/ecfr/base.rb
Direct Known Subclasses
AdminService::Base, DiffService::Base, OfrProfileService::Base, PrinceXmlService::Base, PrinceXmlService::Pdf, RendererService::Base, SearchService::Base, SubscriptionsService::Base, VarnishCacheService::Base, VersionerService::Base
Defined Under Namespace
Classes: Metadata
Constant Summary collapse
- SUPPORTED_ARRAY_ACCESSORS =
i[empty? first last size]
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#request_data ⇒ Object
readonly
Returns the value of attribute request_data.
-
#response_status ⇒ Object
readonly
Returns the value of attribute response_status.
-
#results ⇒ Object
(also: #all)
readonly
Returns the value of attribute results.
Class Method Summary collapse
- .basic_auth_client_options ⇒ Object
- .metadata(*metadata) ⇒ Object
- .metadata_key(key) ⇒ Object
- .result_key(key) ⇒ Object
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Extensible
Methods included from AttributeMethodDefinition
Methods inherited from Client
build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge
Methods included from ParallelClient
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Base
Returns a new instance of Base.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ecfr/base.rb', line 38 def initialize(attributes = {}, = {}) = {base: true} = .merge() @response_status = .delete(:response_status) @request_data = .delete(:request_data) # - handle result_root only if the first time instantiating # the class from the results # - some responses won't be a parsed attribute hash if [:base] && attributes.is_a?(Hash) = Metadata.new(attributes.delete(self.class.)) if result_root && attributes[result_root] @results = attributes[result_root].map do |r| self.class.new(r, base: false) end end end super(attributes) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
32 33 34 |
# File 'lib/ecfr/base.rb', line 32 def end |
#request_data ⇒ Object (readonly)
Returns the value of attribute request_data.
32 33 34 |
# File 'lib/ecfr/base.rb', line 32 def request_data @request_data end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
32 33 34 |
# File 'lib/ecfr/base.rb', line 32 def response_status @response_status end |
#results ⇒ Object (readonly) Also known as: all
Returns the value of attribute results.
32 33 34 |
# File 'lib/ecfr/base.rb', line 32 def results @results end |
Class Method Details
.basic_auth_client_options ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ecfr/base.rb', line 19 def self. { basic_auth: { username: Ecfr.config.ecfr_basic_auth_username, password: Ecfr.config.ecfr_basic_auth_password } } end |
.metadata(*metadata) ⇒ Object
28 29 30 |
# File 'lib/ecfr/base.rb', line 28 def self.(*) Metadata.attribute(*) end |
.metadata_key(key) ⇒ Object
15 16 17 |
# File 'lib/ecfr/base.rb', line 15 def self.(key) self. = key.to_s end |
.result_key(key) ⇒ Object
11 12 13 |
# File 'lib/ecfr/base.rb', line 11 def self.result_key(key) self.result_root = key.to_s end |
Instance Method Details
#each ⇒ Object
61 62 63 |
# File 'lib/ecfr/base.rb', line 61 def each @results.each { |result| yield result } end |