Class: Foobara::AttributesTransformers
- Inherits:
-
TypeDeclarations::TypedTransformer
- Object
- Value::Processor
- Value::Transformer
- TypeDeclarations::TypedTransformer
- Foobara::AttributesTransformers
- Defined in:
- foobara-0.0.130/projects/type_declarations/src/attributes_transformers.rb,
foobara-0.0.130/projects/type_declarations/src/attributes_transformers/only.rb,
foobara-0.0.130/projects/type_declarations/src/attributes_transformers/reject.rb,
foobara-0.0.130/projects/type_declarations/src/attributes_transformers/from_yaml.rb
Defined Under Namespace
Classes: FromYaml, Only, Reject
Instance Attribute Summary
Attributes inherited from Value::Processor
#created_in_namespace, #declaration_data, #parent_declaration_data
Class Method Summary collapse
-
.from_yaml(*attribute_names) ⇒ Object
TODO: dry this up with a .subclass method in AttributesTransformers?.
- .only(*attribute_names) ⇒ Object
- .reject(*attribute_names) ⇒ Object
- .symbol_for_attribute_names(attribute_names) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ AttributesTransformers
constructor
A new instance of AttributesTransformers.
Methods inherited from TypeDeclarations::TypedTransformer
from, #from, #from_type, #from_type_declaration, #has_from_type?, #has_to_type?, #process_value, requires_declaration_data?, requires_parent_declaration_data?, to, #to, #to_type, #to_type_declaration
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, #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
#initialize ⇒ AttributesTransformers
Returns a new instance of AttributesTransformers.
9 10 11 12 13 14 15 |
# File 'foobara-0.0.130/projects/type_declarations/src/attributes_transformers.rb', line 9 def initialize(...) super unless scoped_path_set? self.scoped_path = self.class.scoped_path end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::Value::Processor
Class Method Details
.from_yaml(*attribute_names) ⇒ Object
TODO: dry this up with a .subclass method in AttributesTransformers?
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'foobara-0.0.130/projects/type_declarations/src/attributes_transformers/from_yaml.rb', line 5 def from_yaml(*attribute_names) symbol = symbol_for_attribute_names(attribute_names) existing = FromYaml.(symbol, mode: Namespace::LookupMode::DIRECT) return existing if existing transformer_class = Class.new(FromYaml) transformer_class.from_yaml_attributes = attribute_names Namespace::NamespaceHelpers.(transformer_class, set_namespace: true) transformer_class. = transformer_class.scoped_namespace transformer_class.scoped_namespace.(transformer_class) transformer_class end |
.only(*attribute_names) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'foobara-0.0.130/projects/type_declarations/src/attributes_transformers/only.rb', line 4 def only(*attribute_names) symbol = symbol_for_attribute_names(attribute_names) existing = Only.(symbol, mode: Namespace::LookupMode::DIRECT) return existing if existing transformer_class = Class.new(Only) transformer_class.only_attributes = attribute_names Namespace::NamespaceHelpers.(transformer_class, set_namespace: true) transformer_class. = transformer_class.scoped_namespace transformer_class.scoped_namespace.(transformer_class) transformer_class end |
.reject(*attribute_names) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'foobara-0.0.130/projects/type_declarations/src/attributes_transformers/reject.rb', line 4 def reject(*attribute_names) transformer_class = Class.new(Reject) transformer_class.reject_attributes = attribute_names Namespace::NamespaceHelpers.(transformer_class, set_namespace: true) transformer_class. = transformer_class.scoped_namespace transformer_class.scoped_namespace.(transformer_class) transformer_class end |
.symbol_for_attribute_names(attribute_names) ⇒ Object
4 5 6 |
# File 'foobara-0.0.130/projects/type_declarations/src/attributes_transformers.rb', line 4 def symbol_for_attribute_names(attribute_names) attribute_names.sort.join("__")&.to_sym end |