Class: Foobara::BuiltinTypes::Model::Casters::Hash
- Inherits:
-
Attributes::Casters::Hash
- Object
- Value::Processor
- Value::Transformer
- Value::Caster
- Attributes::Casters::Hash
- Foobara::BuiltinTypes::Model::Casters::Hash
- Defined in:
- foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Value::Processor
#created_in_namespace, #declaration_data, #parent_declaration_data
Class Method Summary collapse
Instance Method Summary collapse
- #build_method(_symbolized_attributes) ⇒ Object
- #cast(attributes) ⇒ Object
- #expected_type_symbol ⇒ Object
- #model_class ⇒ Object
Methods inherited from Attributes::Casters::Hash
#applicable?, #applies_message
Methods inherited from Value::Caster
#applicable?, #applies_message, create, foobara_manifest, requires_declaration_data?, subclass, #transform
Methods inherited from Value::Transformer
create, error_classes, foobara_manifest, #process_value, subclass, #transform
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?, #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::Value::Processor
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::Value::Processor
Class Method Details
.requires_parent_declaration_data? ⇒ Boolean
7 8 9 |
# File 'foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb', line 7 def requires_parent_declaration_data? true end |
Instance Method Details
#build_method(_symbolized_attributes) ⇒ Object
38 39 40 |
# File 'foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb', line 38 def build_method(_symbolized_attributes) :new end |
#cast(attributes) ⇒ Object
12 13 14 15 16 |
# File 'foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb', line 12 def cast(attributes) symbolized_attributes = super model_class.send(build_method(symbolized_attributes), symbolized_attributes) end |
#expected_type_symbol ⇒ Object
34 35 36 |
# File 'foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb', line 34 def expected_type_symbol :model end |
#model_class ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'foobara-0.0.110/projects/model/src/extensions/builtin_types/model/casters/hash.rb', line 18 def model_class type = parent_declaration_data[:type] if type == expected_type_symbol model_class_name = parent_declaration_data[:model_class] if Object.const_defined?(model_class_name) Object.const_get(parent_declaration_data[:model_class]) else Namespace.current.(model_class_name).target_class end else Namespace.current.(type).target_class end end |