Class: SmartCore::Initializer::Attribute::Value::Base Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/initializer/attribute/value/base.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.

Since:

  • 0.8.0

Version:

  • 0.11.0

Direct Known Subclasses

Option, Param

Constant Summary collapse

PRIVACY_MODES =

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.

Returns:

  • (Hash<Symbol,Symbol>)

Since:

  • 0.8.0

{
  public:    :public,
  protected: :protected,
  private:   :private
}.freeze
DEFAULT_PRIVACY_MODE =

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.

Returns:

  • (Symbol)

Since:

  • 0.8.0

PRIVACY_MODES[:public]
DEFAULT_FINALIZER =

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.

Returns:

  • (Proc)

Since:

  • 0.8.0

proc { |value| value }.freeze
DEFAULT_AS =

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.

Returns:

  • (NilClass)

Since:

  • 0.8.0

nil
DEFAULT_MUTABLE =

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.

Returns:

  • (Boolean)

Since:

  • 0.8.0

false

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, name, type, type_system, privacy, finalizer, 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.

Parameters:

Since:

  • 0.8.0



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 111

def initialize(klass, name, type, type_system, privacy, finalizer, cast, mutable, as)
  @klass = klass
  @name = name
  @type = type
  @type_system = type_system
  @privacy = privacy
  @finalizer = finalizer
  @cast = cast
  @mutable = mutable
  @as = as
end

Instance Attribute Details

#asString, ... (readonly)

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.

Returns:

  • (String, Symbol, NilClass)

Since:

  • 0.8.0



96
97
98
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 96

def as
  @as
end

#castBoolean (readonly) Also known as: cast?

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.

Returns:

  • (Boolean)

Since:

  • 0.8.0



82
83
84
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 82

def cast
  @cast
end

#finalizerSmartCore::Initializer::Attribute::Finalizer::AnonymousBlock, SmartCore::Initializer::Attribute::Finalizer::InstanceMethod (readonly)

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.



76
77
78
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 76

def finalizer
  @finalizer
end

#klassClass (readonly)

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.

Returns:

  • (Class)

Since:

  • 0.12.0



45
46
47
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 45

def klass
  @klass
end

#mutableBoolean (readonly) Also known as: mutable?

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.

Returns:

  • (Boolean)

Since:

  • 0.8.0



89
90
91
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 89

def mutable
  @mutable
end

#nameSymbol (readonly)

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.

Returns:

  • (Symbol)

Since:

  • 0.8.0



51
52
53
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 51

def name
  @name
end

#privacySymbol (readonly)

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.

Returns:

  • (Symbol)

Since:

  • 0.8.0



69
70
71
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 69

def privacy
  @privacy
end

#typeSmartCore::Initializer::TypeSystem::Interop (readonly)

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.



57
58
59
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 57

def type
  @type
end

#type_systemClass<SmartCore::Initilizer::TypeSystem::Interop> (readonly)

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.

Returns:

  • (Class<SmartCore::Initilizer::TypeSystem::Interop>)

Since:

  • 0.8.0



63
64
65
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 63

def type_system
  @type_system
end

Instance Method Details

#validate!(value) ⇒ 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.

Parameters:

  • value (Any)

Raises:

Since:

  • 0.8.0

Version:

  • 0.11.0



131
132
133
134
135
136
137
138
139
# File 'lib/smart_core/initializer/attribute/value/base.rb', line 131

def validate!(value)
  unless type.valid?(value)
    raise(
      SmartCore::Initializer::IncorrectTypeError,
      "Validation of attribute `#{klass}##{name}` failed. " \
      "Expected: #{type.identifier}, got: #{truncate(value.inspect, 100)}",
    )
  end
end