Module: SmartCore::Types::Primitive::Factory::RuntimeTypeBuilder Private
- Defined in:
- lib/smart_core/types/primitive/factory/runtime_type_builder.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .build_with_runtime(type_name, type_category, runtime_attributes) ⇒ SmartCore::Types::Primitive private
Instance Method Summary collapse
-
#initialize_clone(new_instance, cloneable_instance) ⇒ void
private
rubocop:disable Style/AccessModifierDeclarations, Metrics/AbcSize, Layout/LineLength.
Class Method Details
.build_with_runtime(type_name, type_category, runtime_attributes) ⇒ SmartCore::Types::Primitive
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/smart_core/types/primitive/factory/runtime_type_builder.rb', line 14 def build_with_runtime(type_name, type_category, runtime_attributes) type = type_category.const_get(type_name) type.runtime_attributes_checker.check!(runtime_attributes) type.clone.tap do |type_with_custom_runtime| type_with_custom_runtime.instance_variable_set( :@runtime_attributes, runtime_attributes.freeze ) end end |
Instance Method Details
#initialize_clone(new_instance, cloneable_instance) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
rubocop:disable Style/AccessModifierDeclarations, Metrics/AbcSize, Layout/LineLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/smart_core/types/primitive/factory/runtime_type_builder.rb', line 33 public def initialize_clone(new_instance, cloneable_instance) name_clone = cloneable_instance.instance_variable_get(:@name) category_clone = cloneable_instance.instance_variable_get(:@category) validator_clone = cloneable_instance.instance_variable_get(:@validator).___copy_for___(new_instance) caster_clone = cloneable_instance.instance_variable_get(:@caster) runtime_attributes_clone = cloneable_instance.instance_variable_get(:@runtime_attributes).clone runtime_attributes_checker_clone = cloneable_instance.instance_variable_get(:@runtime_attributes_checker).___copy_for___(new_instance) lock_clone = SmartCore::Engine::Lock.new nilable_clone = nil new_instance.instance_variable_set(:@name, name_clone) new_instance.instance_variable_set(:@category, category_clone) new_instance.instance_variable_set(:@validator, validator_clone) new_instance.instance_variable_set(:@caster, caster_clone) new_instance.instance_variable_set(:@runtime_attributes, runtime_attributes_clone) new_instance.instance_variable_set(:@runtime_attributes_checker, runtime_attributes_checker_clone) new_instance.instance_variable_set(:@lock_clone, lock_clone) new_instance.instance_variable_set(:@nilable, nilable_clone) end |