Class: SmartCore::Initializer::Constructor::Definer Private
- Inherits:
-
Object
- Object
- SmartCore::Initializer::Constructor::Definer
- Defined in:
- lib/smart_core/initializer/constructor/definer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
- #define_init_extension(block) ⇒ void private
- #define_option(name, type, type_system, privacy, finalize, cast, mutable, as, default, optional) ⇒ void private
- #define_options(*names, mutable:, privacy:) ⇒ void private
- #define_parameter(name, type, type_system, privacy, finalize, cast, mutable, as) ⇒ void private
- #define_parameters(*names, mutable:, privacy:) ⇒ void private
- #initialize(klass) ⇒ void constructor private
Constructor Details
#initialize(klass) ⇒ 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.
14 15 16 17 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 14 def initialize(klass) @klass = klass @lock = SmartCore::Engine::ReadWriteLock.new end |
Instance Method Details
#define_init_extension(block) ⇒ 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.
25 26 27 28 29 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 25 def define_init_extension(block) @lock.write_sync do add_init_extension(build_init_extension(block)) end end |
#define_option(name, type, type_system, privacy, finalize, cast, mutable, as, default, optional) ⇒ 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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 114 def define_option( name, type, type_system, privacy, finalize, cast, mutable, as, default, optional ) @lock.write_sync do attribute = build_option_attribute( name, type, type_system, privacy, finalize, cast, mutable, as, default, optional ) prevent_parameter_overlap(attribute) add_option(attribute) end end |
#define_options(*names, mutable:, privacy:) ⇒ 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.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 152 def (*names, mutable:, privacy:) @lock.write_sync do names.map do |name| build_option_attribute( name, klass.__initializer_settings__.generic_type_object, klass.__initializer_settings__.type_system, privacy, SmartCore::Initializer::Attribute::Value::Option::DEFAULT_FINALIZER, klass.__initializer_settings__.auto_cast, mutable, SmartCore::Initializer::Attribute::Value::Option::DEFAULT_AS, SmartCore::Initializer::Attribute::Value::Option::UNDEFINED_DEFAULT, SmartCore::Initializer::Attribute::Value::Option::DEFAULT_OPTIONAL ).tap do |attribute| prevent_parameter_overlap(attribute) end end.each do |attribute| add_option(attribute) end end end |
#define_parameter(name, type, type_system, privacy, finalize, cast, mutable, as) ⇒ 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 44 def define_parameter( name, type, type_system, privacy, finalize, cast, mutable, as ) @lock.write_sync do attribute = build_param_attribute( name, type, type_system, privacy, finalize, cast, mutable, as ) prevent_option_overlap(attribute) add_parameter(attribute) end end |
#define_parameters(*names, mutable:, privacy:) ⇒ 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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/smart_core/initializer/constructor/definer.rb', line 78 def define_parameters(*names, mutable:, privacy:) @lock.write_sync do names.map do |name| build_param_attribute( name, klass.__initializer_settings__.generic_type_object, klass.__initializer_settings__.type_system, privacy, SmartCore::Initializer::Attribute::Value::Param::DEFAULT_FINALIZER, klass.__initializer_settings__.auto_cast, mutable, SmartCore::Initializer::Attribute::Value::Param::DEFAULT_AS ).tap do |attribute| prevent_option_overlap(attribute) end end.each do |attribute| add_parameter(attribute) end end end |