Class: Eco::API::UseCases::GraphQL::Helpers::Location::Command::Result
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Helpers::Location::Command::Result
- Defined in:
- lib/eco/api/usecases/graphql/helpers/location/command/result.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #as_json ⇒ Object
- #command ⇒ Object
- #command_id ⇒ Object
- #command_input_data ⇒ Object
- #command_result ⇒ Object
- #error ⇒ Object
- #error? ⇒ Boolean
- #error_msg ⇒ Object
-
#initialize(input, result) ⇒ Result
constructor
A new instance of Result.
- #node_id ⇒ Object
- #pending? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(input, result) ⇒ Result
Returns a new instance of Result.
5 6 7 8 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 5 def initialize(input, result) @input = input @result = result 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/result.rb', line 3 def input @input end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 3 def result @result end |
Instance Method Details
#applied? ⇒ Boolean
26 27 28 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 26 def applied? !pending? end |
#as_json ⇒ Object
62 63 64 65 66 67 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 62 def as_json { "request" => input, "response" => result.doc } end |
#command ⇒ Object
10 11 12 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 10 def command input.keys.first end |
#command_id ⇒ Object
57 58 59 60 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 57 def command_id return nil unless result command_result["id"] end |
#command_input_data ⇒ Object
14 15 16 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 14 def command_input_data input[command] end |
#command_result ⇒ Object
53 54 55 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 53 def command_result result&.command end |
#error ⇒ Object
34 35 36 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 34 def error result&.error end |
#error? ⇒ Boolean
38 39 40 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 38 def error? !!error end |
#error_msg ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 42 def error_msg return nil unless error? msg = '' msg << "(#{command} '#{node_id}') #{error.message}\n" || '' return msg if error.validationErrors.empty? msg << " • " + error.validationErrors.map do |err| err. end.join("\n • ") msg end |
#node_id ⇒ Object
18 19 20 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 18 def node_id command_input_data[:nodeId] end |
#pending? ⇒ Boolean
22 23 24 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 22 def pending? !result || !success? end |
#success? ⇒ Boolean
30 31 32 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/result.rb', line 30 def success? result&.ok end |