Class: Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results
- Defined in:
- lib/eco/api/usecases/graphql/helpers/location/command/results.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #applied ⇒ Object
- #applied? ⇒ Boolean
- #count ⇒ Object
-
#error ⇒ Object
Overal errors (i.e. ID clashes between different structures).
- #error? ⇒ Boolean
- #errored ⇒ Object
- #errored? ⇒ Boolean
- #first_errored ⇒ Object
- #first_errored_idx ⇒ Object
-
#force? ⇒ Boolean
Was this configured to force-continue on command error?.
- #idx(result) ⇒ Object
-
#initialize(input, response) ⇒ Results
constructor
A new instance of Results.
- #input_idx(input) ⇒ Object
- #input_result(input) ⇒ Object
- #last_applied ⇒ Object
- #last_applied_idx ⇒ Object
- #pending ⇒ Object
- #results ⇒ Object
- #some_applied? ⇒ Boolean
- #some_pending? ⇒ Boolean
- #stats ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(input, response) ⇒ Results
Returns a new instance of Results.
5 6 7 8 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 5 def initialize(input, response) @input = input @response = response end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 3 def input @input end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 3 def response @response end |
Instance Method Details
#applied ⇒ Object
80 81 82 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 80 def applied @applied ||= results.select(&:applied?) end |
#applied? ⇒ Boolean
84 85 86 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 84 def applied? results.all?(&:applied?) end |
#count ⇒ Object
48 49 50 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 48 def count results.count end |
#error ⇒ Object
Overal errors (i.e. ID clashes between different structures)
30 31 32 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 30 def error response&.error end |
#error? ⇒ Boolean
34 35 36 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 34 def error? !!error end |
#errored ⇒ Object
64 65 66 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 64 def errored @errored ||= results.select(&:error?) end |
#errored? ⇒ Boolean
68 69 70 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 68 def errored? errored.any? end |
#first_errored ⇒ Object
72 73 74 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 72 def first_errored errored.first end |
#first_errored_idx ⇒ Object
76 77 78 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 76 def first_errored_idx idx(first_errored) end |
#force? ⇒ Boolean
Was this configured to force-continue on command error?
19 20 21 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 19 def force? input[:force] end |
#idx(result) ⇒ Object
60 61 62 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 60 def idx(result) results.index(result) end |
#input_idx(input) ⇒ Object
56 57 58 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 56 def input_idx(input) results.index(input_result(input)) end |
#input_result(input) ⇒ Object
52 53 54 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 52 def input_result(input) results_by_input[input] end |
#last_applied ⇒ Object
92 93 94 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 92 def last_applied applied.last end |
#last_applied_idx ⇒ Object
96 97 98 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 96 def last_applied_idx idx(last_applied) end |
#pending ⇒ Object
100 101 102 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 100 def pending @pending ||= results.select(&:pending?) end |
#results ⇒ Object
42 43 44 45 46 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 42 def results @results ||= input_commands.zip(response_results).each_with_object([]) do |(i, r), results| results << Result.new(i, r) end end |
#some_applied? ⇒ Boolean
88 89 90 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 88 def some_applied? applied.count.positive? end |
#some_pending? ⇒ Boolean
104 105 106 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 104 def some_pending? !pending.empty? end |
#stats ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 10 def stats msg = '' msg << " • Errored: #{errored.count} #{first_err_str}\n" if errored? msg << " • Applied: #{errored.count} #{last_okay_str}\n" if some_applied? msg << " • Pending: #{pending.count}\n" if some_pending? msg end |
#success? ⇒ Boolean
38 39 40 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 38 def success? !error? && results.all?(&:success?) end |