Class: Crossbeam::Result
- Inherits:
-
Struct
- Object
- Struct
- Crossbeam::Result
- Defined in:
- lib/crossbeam/result.rb
Overview
Used as a data container to hold a service calls results, errors, etc. class Result < Struct.new(:called, :errors, :failure, :results)
Instance Attribute Summary collapse
-
#called ⇒ Object
Returns the value of attribute called.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failure ⇒ Object
Returns the value of attribute failure.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#called? ⇒ Boolean
The serivce can’t officially be a failure/pass if it hasn’t been “called”.
-
#errors? ⇒ Boolean
Determine if the service call has any errors.
-
#failure? ⇒ Boolean
Determine if the service call has failed to uccessfully complete.
-
#initialize(called: false, errors: nil, failure: false, results: nil) ⇒ Result
constructor
Used to initialize a service calls results, errors, and stats.
-
#success? ⇒ Boolean
Determine if the service call has successfully ran.
Constructor Details
#initialize(called: false, errors: nil, failure: false, results: nil) ⇒ Result
Used to initialize a service calls results, errors, and stats
22 23 24 25 26 27 28 29 |
# File 'lib/crossbeam/result.rb', line 22 def initialize(called: false, errors: nil, failure: false, results: nil) super(called, errors, failure, results) self.called = called self.errors = Crossbeam::Errors.new self.failure = failure self.results = nil end |
Instance Attribute Details
#called ⇒ Object
Returns the value of attribute called
11 12 13 |
# File 'lib/crossbeam/result.rb', line 11 def called @called end |
#errors ⇒ Object
Returns the value of attribute errors
11 12 13 |
# File 'lib/crossbeam/result.rb', line 11 def errors @errors end |
#failure ⇒ Object
Returns the value of attribute failure
11 12 13 |
# File 'lib/crossbeam/result.rb', line 11 def failure @failure end |
#results ⇒ Object
Returns the value of attribute results
11 12 13 |
# File 'lib/crossbeam/result.rb', line 11 def results @results end |
Instance Method Details
#called? ⇒ Boolean
The serivce can’t officially be a failure/pass if it hasn’t been “called”
34 35 36 |
# File 'lib/crossbeam/result.rb', line 34 def called? called || false end |
#errors? ⇒ Boolean
Determine if the service call has any errors
41 42 43 |
# File 'lib/crossbeam/result.rb', line 41 def errors? (errors.is_a?(Hash) && errors.any?) || false end |
#failure? ⇒ Boolean
Determine if the service call has failed to uccessfully complete
48 49 50 |
# File 'lib/crossbeam/result.rb', line 48 def failure? called? && issues? end |
#success? ⇒ Boolean
Determine if the service call has successfully ran
55 56 57 |
# File 'lib/crossbeam/result.rb', line 55 def success? called? && !issues? end |