Module: Foobara::CommandPatternImplementation::Concerns::Reflection::ClassMethods
- Defined in:
- foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #command_name ⇒ Object
- #errors_types_depended_on ⇒ Object
- #foobara_manifest ⇒ Object
- #inputs_types_depended_on ⇒ Object
- #reset_all ⇒ Object
- #result_types_depended_on ⇒ Object
- #types_depended_on ⇒ Object
Instance Method Details
#all ⇒ Object
14 15 16 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 14 def all @all ||= [] end |
#command_name ⇒ Object
89 90 91 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 89 def command_name Util.non_full_name(self) end |
#errors_types_depended_on ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 167 def errors_types_depended_on remove_sensitive = TypeDeclarations. if defined?(@errors_types_depended_on) && @errors_types_depended_on.key?(remove_sensitive) return @errors_types_depended_on[remove_sensitive] end @errors_types_depended_on ||= {} @errors_types_depended_on[remove_sensitive] = begin error_classes = possible_errors.map(&:error_class) error_classes.map(&:types_depended_on).inject(:|) || Set.new end end |
#foobara_manifest ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 22 def to_include = TypeDeclarations. depends_on = self.depends_on.map do |command_name| other_command = Foobara::Namespace.global.(command_name, mode: Foobara::Namespace::LookupMode::ABSOLUTE) if to_include to_include << other_command end other_command. end.sort types = types_depended_on.map do |t| if to_include to_include << t end t. end.sort inputs_types_depended_on = self.inputs_types_depended_on.map do |t| if to_include to_include << t end t. end.sort result_types_depended_on = self.result_types_depended_on.map do |t| if to_include to_include << t end t. end.sort errors_types_depended_on = self.errors_types_depended_on.map do |t| if to_include to_include << t end t. end.sort possible_errors = self.possible_errors.map do |possible_error| [possible_error.key.to_s, possible_error.] end.sort.to_h h = Util.remove_blank( types_depended_on: types, inputs_types_depended_on:, result_types_depended_on:, errors_types_depended_on:, possible_errors:, depends_on:, # TODO: allow inputs type to be nil or really any type? inputs_type: inputs_type&.reference_or_declaration_data || { type: "::attributes", element_type_declarations: {}, required: [] } ).merge(description:) if result_type # TODO: find a way to represent literal types like "nil" h[:result_type] = result_type.reference_or_declaration_data end super.merge(h) end |
#inputs_types_depended_on ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 121 def inputs_types_depended_on remove_sensitive = TypeDeclarations. if defined?(@inputs_types_depended_on) && @inputs_types_depended_on.key?(remove_sensitive) return @inputs_types_depended_on[remove_sensitive] end @inputs_types_depended_on ||= {} @inputs_types_depended_on[remove_sensitive] = if inputs_type if inputs_type.registered? # TODO: if we ever change from attributes-only inputs type # then this will be handy # :nocov: if !remove_sensitive || !inputs_type.sensitive? Set[inputs_type] else Set.new end # :nocov: else inputs_type.types_depended_on end else Set.new end end |
#reset_all ⇒ Object
18 19 20 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 18 def reset_all remove_instance_variable("@all") if instance_variable_defined?("@all") end |
#result_types_depended_on ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 148 def result_types_depended_on remove_sensitive = TypeDeclarations. if defined?(@result_types_depended_on) && @result_types_depended_on.key?(remove_sensitive) return @result_types_depended_on[remove_sensitive] end @result_types_depended_on ||= {} @result_types_depended_on[remove_sensitive] = if result_type if result_type.registered? Set[result_type] else result_type.types_depended_on end else Set.new end end |
#types_depended_on ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/reflection.rb', line 93 def types_depended_on remove_sensitive = TypeDeclarations. if defined?(@types_depended_on) && @types_depended_on.key?(remove_sensitive) return @types_depended_on[remove_sensitive] end @types_depended_on ||= {} @types_depended_on[remove_sensitive] = begin types = inputs_types_depended_on | result_types_depended_on | errors_types_depended_on unless depends_on_entities.empty? entity_types = depends_on_entities.map(&:entity_type) if remove_sensitive entity_types = entity_types.reject(&:sensitive?) end types |= entity_types types |= entity_types.map(&:types_depended_on).inject(:|) end types end end |