Class: TcoClientCore::Response
- Inherits:
-
Object
- Object
- TcoClientCore::Response
- Extended by:
- Forwardable
- Defined in:
- lib/tco_client_core/response.rb
Instance Method Summary collapse
- #errors ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 |
# File 'lib/tco_client_core/response.rb', line 10 def initialize(raw) @raw = raw @response = JSON.parse(raw) raise ArgumentError, "TcoClientCore::Response response hash required" unless @response.is_a? Hash @response.keys.each do |key| next if key == "errors" define_singleton_method(key) { @response[key] } end end |
Instance Method Details
#errors ⇒ Object
24 25 26 |
# File 'lib/tco_client_core/response.rb', line 24 def errors @response.fetch("errors", {}) end |
#errors? ⇒ Boolean
20 21 22 |
# File 'lib/tco_client_core/response.rb', line 20 def errors? errors.any? end |