Module: Foobara::CommandPatternImplementation::Concerns::InputsType::ClassMethods

Defined in:
foobara-0.2.7/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb

Instance Method Summary collapse

Instance Method Details

#add_inputsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'projects/command/src/command_pattern_implementation/concerns/inputs_type.rb', line 36

def add_inputs(...)
  if inputs_type
    new_type = type_for_declaration(...)
    new_declaration = TypeDeclarations::Attributes.merge(
      inputs_type.declaration_data,
      new_type.declaration_data
    )

    inputs new_declaration
  else
    inputs(...)
  end
end

#inputsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'projects/command/src/command_pattern_implementation/concerns/inputs_type.rb', line 8

def inputs(...)
  old_inputs_type = inputs_type

  old_inputs_type&.possible_errors&.each do |possible_error|
    unregister_possible_error_if_registered(possible_error)
  end

  if defined?(@inputs_association_paths)
    remove_instance_variable(:@inputs_association_paths)
  end

  if defined?(@entity_class_paths)
    remove_instance_variable(:@entity_class_paths)
  end

  type = type_for_declaration(...)

  if type.extends?(BuiltinTypes[:model]) && !type.extends?(BuiltinTypes[:entity])
    type = type.element_types
  end

  @inputs_type = type

  register_possible_input_errors

  @inputs_type
end

#inputs_typeObject



50
51
52
53
54
55
56
# File 'projects/command/src/command_pattern_implementation/concerns/inputs_type.rb', line 50

def inputs_type
  return @inputs_type if defined?(@inputs_type)

  @inputs_type = if superclass < Foobara::Command
                   superclass.inputs_type
                 end
end

#inputs_type_declarationObject



58
59
60
# File 'projects/command/src/command_pattern_implementation/concerns/inputs_type.rb', line 58

def inputs_type_declaration
  inputs_type.declaration_data
end