Class: Foobara::DetachedEntityType
- Inherits:
-
Types::Type
- Object
- Value::Processor
- Value::Processor::Multi
- Value::Processor::Pipeline
- Types::Type
- Foobara::DetachedEntityType
- Defined in:
- foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb
Instance Attribute Summary
Attributes inherited from Types::Type
#base_type, #casters, #description, #element_processors, #element_type, #element_types, #is_builtin, #name, #processor_classes_requiring_type, #raw_declaration_data, #sensitive, #sensitive_exposed, #structure_count, #target_classes, #transformers, #type_symbol, #validators
Attributes inherited from Value::Processor::Multi
Attributes inherited from Value::Processor
#created_in_namespace, #declaration_data, #parent_declaration_data
Class Method Summary collapse
- .model_base_class_requires_conversion?(model_base_class) ⇒ Boolean
- .model_base_classes_requiring_conversion ⇒ Object
- .type_requires_conversion?(type) ⇒ Boolean
- .types_requiring_conversion ⇒ Object
Instance Method Summary collapse
- #base_type_for_manifest ⇒ Object
- #detached_context? ⇒ Boolean
- #foobara_manifest ⇒ Object
- #types_to_add_to_manifest ⇒ Object
Methods inherited from Types::Type
#applicable?, #apply_all_processors_needing_type!, #builtin?, #cast, #cast!, #each_processor_class_requiring_type, #element_processor, #extends?, #extends_type?, #foobara_manifest_reference, #full_type_name, #full_type_symbol, #has_sensitive_types?, #initialize, #processor_manifest, #processors, #reference_or_declaration_data, #registered?, #remove_processor_by_symbol, requires_declaration_data?, #sensitive?, #sensitive_exposed?, #supported_processor_manifest, #target_class, #validate_processors!, #validation_errors, #value_caster, #value_transformer, #value_validator
Methods included from IsManifestable
#foobara_domain, #foobara_organization, #scoped_clear_caches
Methods included from Types::Type::Concerns::Reflection
#deep_types_depended_on, #inspect, #type_at_path, #types_depended_on
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Methods included from Types::Type::Concerns::SupportedProcessorRegistration
#all_supported_processor_classes, #find_supported_processor_class, #register_supported_processor_class, #supported_processor_classes
Methods inherited from Value::Processor::Pipeline
foobara_manifest, #process_outcome, #process_value
Methods inherited from Value::Processor::Multi
#applicable?, #error_classes, #initialize, #possible_errors, #processor_names, #register, requires_declaration_data?
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, #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
Constructor Details
This class inherits a constructor from Foobara::Types::Type
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::Value::Processor
Class Method Details
.model_base_class_requires_conversion?(model_base_class) ⇒ Boolean
16 17 18 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 16 def model_base_class_requires_conversion?(model_base_class) model_base_classes_requiring_conversion.include?(model_base_class) end |
.model_base_classes_requiring_conversion ⇒ Object
8 9 10 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 8 def model_base_classes_requiring_conversion @model_base_classes_requiring_conversion ||= Set.new end |
.type_requires_conversion?(type) ⇒ Boolean
12 13 14 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 12 def type_requires_conversion?(type) types_requiring_conversion.include?(type) end |
.types_requiring_conversion ⇒ Object
4 5 6 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 4 def types_requiring_conversion @types_requiring_conversion ||= Set.new end |
Instance Method Details
#base_type_for_manifest ⇒ Object
56 57 58 59 60 61 62 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 56 def base_type_for_manifest if detached_context? BuiltinTypes[:detached_entity] else super end end |
#detached_context? ⇒ Boolean
64 65 66 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 64 def detached_context? TypeDeclarations. end |
#foobara_manifest ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 21 def manifest = super if detached_context? declaration_data = manifest[:declaration_data] if self.class.type_requires_conversion?(declaration_data[:type]) declaration_data = declaration_data.merge(type: :detached_entity) end if self.class.model_base_class_requires_conversion?(declaration_data[:model_base_class]) declaration_data = declaration_data.merge(model_base_class: "Foobara::DetachedEntity") end # TODO: remove private attributes, add delegated attributes # re: delegated attribute type... it can be required if required entire way, can be # allow_nil if allow_nil anywhere along the way. # remove private and delegated from the manifest hash. manifest = manifest.merge(declaration_data:) end manifest end |
#types_to_add_to_manifest ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'foobara-0.0.110/projects/detached_entity/src/detached_entity_type.rb', line 45 def types_to_add_to_manifest types = super if detached_context? types.delete(base_type) types.unshift(base_type_for_manifest) end types end |