Class: AttrObject::Value
- Inherits:
-
Object
- Object
- AttrObject::Value
- Defined in:
- lib/attr_object/value.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #cast ⇒ Object
-
#initialize(klass, value) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(klass, value) ⇒ Value
Returns a new instance of Value.
6 7 8 9 |
# File 'lib/attr_object/value.rb', line 6 def initialize klass, value @klass = klass @value = value end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/attr_object/value.rb', line 3 def klass @klass end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/attr_object/value.rb', line 4 def value @value end |
Instance Method Details
#cast ⇒ Object
15 16 17 18 |
# File 'lib/attr_object/value.rb', line 15 def cast return if @value.nil? @cast ||= @klass.new @value end |