Class: AttrObject::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/attr_object/value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#klassObject (readonly)

Returns the value of attribute klass.



3
4
5
# File 'lib/attr_object/value.rb', line 3

def klass
  @klass
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/attr_object/value.rb', line 4

def value
  @value
end

Instance Method Details

#castObject



15
16
17
18
# File 'lib/attr_object/value.rb', line 15

def cast
  return if @value.nil?
  @cast ||= @klass.new @value
end