Class: SmartCore::Initializer::Attribute::Value::Option Private
- Defined in:
- lib/smart_core/initializer/attribute/value/option.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.
Constant Summary collapse
- UNDEFINED_DEFAULT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
::Object.new.tap(&:freeze)
- DEFAULT_OPTIONAL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
false
Constants inherited from Base
Base::DEFAULT_AS, Base::DEFAULT_FINALIZER, Base::DEFAULT_MUTABLE, Base::DEFAULT_PRIVACY_MODE, Base::PRIVACY_MODES
Instance Attribute Summary collapse
- #optional ⇒ Boolean (also: #optional?) readonly private
Attributes inherited from Base
#as, #cast, #finalizer, #klass, #mutable, #name, #privacy, #type, #type_system
Instance Method Summary collapse
- #default ⇒ Any private
- #dup ⇒ SmartCore::Initializer::Attribute::Value::Option private
- #has_default? ⇒ Boolean private
- #initialize(klass, name, type, type_system, privacy, finalizer, cast, mutable, as, default, optional) ⇒ void constructor private
Methods inherited from Base
Constructor Details
#initialize(klass, name, type, type_system, privacy, finalizer, 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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/smart_core/initializer/attribute/value/option.rb', line 41 def initialize( klass, name, type, type_system, privacy, finalizer, cast, mutable, as, default, optional ) super(klass, name, type, type_system, privacy, finalizer, cast, mutable, as) @default = default @optional = optional end |
Instance Attribute Details
#optional ⇒ Boolean (readonly) Also known as: optional?
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.
23 24 25 |
# File 'lib/smart_core/initializer/attribute/value/option.rb', line 23 def optional @optional end |
Instance Method Details
#default ⇒ Any
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.
73 74 75 76 77 78 79 80 |
# File 'lib/smart_core/initializer/attribute/value/option.rb', line 73 def default raise( SmartCore::Initializer::NoDefaultValueError, "Attribute #{name} has no default value" ) if @default.equal?(UNDEFINED_DEFAULT) @default.is_a?(Proc) ? @default.call : @default.dup end |
#dup ⇒ SmartCore::Initializer::Attribute::Value::Option
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.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/smart_core/initializer/attribute/value/option.rb', line 86 def dup default = @default.equal?(UNDEFINED_DEFAULT) ? @default : @default.dup self.class.new( klass, name.dup, type, type_system, privacy, finalizer.dup, cast, mutable, as, default, optional ) end |
#has_default? ⇒ Boolean
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.
63 64 65 |
# File 'lib/smart_core/initializer/attribute/value/option.rb', line 63 def has_default? !@default.equal?(UNDEFINED_DEFAULT) end |