Class: Eco::API::UseCases::GraphQL::Helpers::Location::Command::InputUnitResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, response) ⇒ InputUnitResponse

Returns a new instance of InputUnitResponse.



5
6
7
8
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 5

def initialize(input, response)
  @input    = input
  @response = response
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 3

def input
  @input
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 3

def response
  @response
end

Instance Method Details

#commandsObject



18
19
20
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 18

def commands
  input[:commands]
end

#conflictingIdsObject

rubocop:disable Naming/MethodName



47
48
49
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 47

def conflictingIds # rubocop:disable Naming/MethodName

  draft_conflicting_ids & target_ids
end

#conflictingIds?Boolean

rubocop:disable Naming/MethodName

Returns:

  • (Boolean)


43
44
45
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 43

def conflictingIds? # rubocop:disable Naming/MethodName

  conflictingIds.any?
end

#draftObject



10
11
12
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 10

def draft
  response&.draft
end

#error?Boolean Also known as: errors?

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 31

def error?
  return false if response.nil?
  return true  if conflictingIds?

  response.error? # draft might have previous, but we will stop anyway!

end

#error_docObject

brief summary of the error



23
24
25
26
27
28
29
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 23

def error_doc
  if (err_doc = response&.error_doc)
    return err_doc
  end

  conflictingIds if conflictingIds?
end

#ok?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 39

def ok?
  !errors?
end

#structureObject



14
15
16
# File 'lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb', line 14

def structure
  draft&.structure
end