Class: Foobara::TypeDeclarations::RemoveSensitiveValuesTransformer
- Inherits:
-
TypedTransformer
- Object
- Value::Processor
- Value::Transformer
- TypedTransformer
- Foobara::TypeDeclarations::RemoveSensitiveValuesTransformer
- Defined in:
- foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb
Direct Known Subclasses
Model::SensitiveValueRemovers::Model, SensitiveValueRemovers::Array, SensitiveValueRemovers::Attributes
Instance Attribute Summary
Attributes inherited from Value::Processor
#created_in_namespace, #declaration_data, #parent_declaration_data
Instance Method Summary collapse
- #create_all_association_types_in_current_namespace(type) ⇒ Object
- #from ⇒ Object
- #from_type_declaration ⇒ Object
- #sanitize_value(type, value) ⇒ Object
- #to ⇒ Object
- #to_type_declaration ⇒ Object
- #transform(_value) ⇒ Object
Methods inherited from TypedTransformer
from, #from_type, #has_from_type?, #has_to_type?, #initialize, #process_value, requires_declaration_data?, requires_parent_declaration_data?, to, #to_type
Methods inherited from Value::Transformer
create, error_classes, foobara_manifest, #process_value, subclass
Methods inherited from Value::Processor
#always_applicable?, #applicable?, #attribute_name, #build_error, default_declaration_data, #dup_processor, error_class, error_classes, #error_context, #error_message, #error_path, foobara_manifest, #foobara_manifest, #initialize, #inspect, instance, #method_missing, #name, new_with_agnostic_args, #possible_errors, #priority, #process_outcome, #process_outcome!, #process_value, #process_value!, processor_name, requires_declaration_data?, requires_parent_declaration_data?, #respond_to_missing?, #runner, symbol
Methods included from IsManifestable
#foobara_domain, #foobara_manifest, #foobara_organization, #scoped_clear_caches
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Constructor Details
This class inherits a constructor from Foobara::TypeDeclarations::TypedTransformer
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::Value::Processor
Instance Method Details
#create_all_association_types_in_current_namespace(type) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 18 def create_all_association_types_in_current_namespace(type) associations = Foobara::DetachedEntity.construct_deep_associations(type) associations&.values&.reverse&.each do |entity_type| next if entity_type.sensitive? next unless entity_type.has_sensitive_types? declaration = entity_type.declaration_data sanitized_type_declaration = TypeDeclarations.remove_sensitive_types(declaration) # We want to make sure that any types that change due to having sensitive types # has a corresponding registered type in the command registry domain if needed # TODO: this all feels so messy and brittle. Domain.current.(sanitized_type_declaration) end end |
#from ⇒ Object
6 7 8 9 10 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 6 def from(...) super.tap do create_all_association_types_in_current_namespace(from_type) end end |
#from_type_declaration ⇒ Object
39 40 41 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 39 def from_type_declaration TypeDeclarations.remove_sensitive_types(to_type.declaration_data) end |
#sanitize_value(type, value) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 49 def sanitize_value(type, value) if type.has_sensitive_types? sanitized_value = Namespace.use to_type.created_in_namespace do remover_class = TypeDeclarations.sensitive_value_remover_class_for_type(type) remover = remover_class.new(from: type) remover.process_value!(value) end [sanitized_value, sanitized_value != value] else [value, false] end end |
#to ⇒ Object
12 13 14 15 16 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 12 def to(...) super.tap do create_all_association_types_in_current_namespace(to_type) end end |
#to_type_declaration ⇒ Object
35 36 37 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 35 def to_type_declaration TypeDeclarations.remove_sensitive_types(from_type.declaration_data) end |
#transform(_value) ⇒ Object
43 44 45 46 47 |
# File 'foobara-0.0.130/projects/type_declarations/src/remove_sensitive_values_transformer.rb', line 43 def transform(_value) # :nocov: raise "subclass responsibility" # :nocov: end |