Class: GenesisRuby::Api::Response
- Inherits:
-
Object
- Object
- GenesisRuby::Api::Response
- Defined in:
- lib/genesis_ruby/api/response.rb
Overview
Response - process/format an incoming Genesis response
Instance Method Summary collapse
-
#initialize(configuration, request_api_config = {}) ⇒ Response
constructor
A new instance of Response.
-
#method_missing(symbol) ⇒ Object
Dynamic Helper Methods.
-
#parse_response(network) ⇒ Object
Parse the response from the given Network.
-
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Respond to missing implementation.
-
#response_object ⇒ Object
Default Response Object initialization.
-
#response_raw ⇒ Object
Default Response Raw initialization.
Constructor Details
#initialize(configuration, request_api_config = {}) ⇒ Response
Returns a new instance of Response.
15 16 17 18 19 20 |
# File 'lib/genesis_ruby/api/response.rb', line 15 def initialize(configuration, request_api_config = {}) @configuration = configuration @object_formatter = GenesisRuby::Utils::ObjectFormatter.new @response_formatter = GenesisRuby::Utils::Formatters::Response::Loader.new @request_api_config = request_api_config end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol) ⇒ Object
Dynamic Helper Methods
42 43 44 45 46 |
# File 'lib/genesis_ruby/api/response.rb', line 42 def method_missing(symbol) super unless GenesisRuby::Api::Constants::States::State.handle_respond_to_states(symbol) handle_method_missing_states(symbol) end |
Instance Method Details
#parse_response(network) ⇒ Object
Parse the response from the given Network
33 34 35 36 37 38 39 |
# File 'lib/genesis_ruby/api/response.rb', line 33 def parse_response(network) @network_context = network @response_raw = @network_context.response_body @response_object = load_parser(@network_context).parse_document(@response_raw) process_response_object end |
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Respond to missing implementation
49 50 51 |
# File 'lib/genesis_ruby/api/response.rb', line 49 def respond_to_missing?(symbol, include_private = false) GenesisRuby::Api::Constants::States::State.handle_respond_to_states(symbol) || super end |
#response_object ⇒ Object
Default Response Object initialization
23 24 25 |
# File 'lib/genesis_ruby/api/response.rb', line 23 def response_object @response_object ||= {} end |
#response_raw ⇒ Object
Default Response Raw initialization
28 29 30 |
# File 'lib/genesis_ruby/api/response.rb', line 28 def response_raw @response_raw ||= '' end |