Class: Foobara::BuiltinTypes::Model::SupportedTransformers::Mutable

Inherits:
TypeDeclarations::Transformer show all
Defined in:
foobara-0.0.125/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb

Instance Attribute Summary

Attributes inherited from Value::Processor

#created_in_namespace, #declaration_data, #parent_declaration_data

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

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, #respond_to_missing?, #runner, symbol

Methods included from IsManifestable

#foobara_domain, #foobara_manifest, #foobara_organization, #scoped_clear_caches

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_declaration_data?Boolean

Returns:

[View source]

7
8
9
# File 'foobara-0.0.125/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb', line 7

def requires_declaration_data?
  true
end

.requires_parent_declaration_data?Boolean

Returns:

[View source]

11
12
13
# File 'foobara-0.0.125/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb', line 11

def requires_parent_declaration_data?
  true
end

Instance Method Details

#transform(record) ⇒ Object

[View source]

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'foobara-0.0.125/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb', line 16

def transform(record)
  if parent_declaration_data.key?(:mutable)
    # hmmmm.... can we really just arbitrarily clobber this?
    # wouldn't that be surprising to calling code that passes in a record/model?
    # One use-case of this seems to be to reduce the amount of possible errors a command reports
    # by declaring that only some subset or none of the attributes are mutable.
    # However, we shouldn't react to this by clobbering the mutable state of the record because it might not
    # be a fresh record fetched from a primary key it might be an already loaded record/model from some other
    # context and that context might be surprised to learn that we've clobbered its mutability status.
    # Solutions?
    # 1. In the case of models, we could duplicate the model if the mutable value is different.
    # 2. But what about entities? We almost need some sort of proxy entity that tightens the mutability?
    record.mutable = parent_declaration_data[:mutable]
  end

  record
end