Class: CemAcpt::Goss::Api::ActionResponse
- Inherits:
-
Object
- Object
- CemAcpt::Goss::Api::ActionResponse
- Defined in:
- lib/cem_acpt/goss/api/action_response.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(host, action, status, body) ⇒ ActionResponse
constructor
A new instance of ActionResponse.
- #inspect ⇒ Object
- #results ⇒ Object
- #results? ⇒ Boolean
- #status ⇒ Object (also: #http_status)
- #success? ⇒ Boolean
- #summary ⇒ Object
- #summary? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host, action, status, body) ⇒ ActionResponse
Returns a new instance of ActionResponse.
9 10 11 12 13 14 15 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 9 def initialize(host, action, status, body) @host = host @action = action @status = status @body = body @metadata = {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 7 def action @action end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 7 def body @body end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 7 def host @host end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 7 def @metadata end |
Instance Method Details
#error ⇒ Object
44 45 46 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 44 def error results.find(&:error) end |
#error? ⇒ Boolean
48 49 50 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 48 def error? !success? && !error.nil? end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 21 def inspect to_s end |
#results ⇒ Object
52 53 54 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 52 def results @results ||= @body['results'].map { |r| ActionResponseResult.new(r) } end |
#results? ⇒ Boolean
56 57 58 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 56 def results? !results.nil? && !results.empty? end |
#status ⇒ Object Also known as: http_status
35 36 37 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 35 def status @status.to_i end |
#success? ⇒ Boolean
40 41 42 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 40 def success? status == 200 end |
#summary ⇒ Object
60 61 62 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 60 def summary @summary ||= ActionResponseSummary.new(@body['summary']) end |
#summary? ⇒ Boolean
64 65 66 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 64 def summary? !summary.nil? && !summary.empty? end |
#to_h ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 25 def to_h { host: host, action: action, status: @status, body: @body, metadata: @metadata, } end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/cem_acpt/goss/api/action_response.rb', line 17 def to_s "#<#{self.class.name}:0x#{object_id.to_s(16)}>" end |