Class: CastedHash::Value
- Inherits:
-
Object
- Object
- CastedHash::Value
- Defined in:
- lib/casted_hash/value.rb
Instance Attribute Summary collapse
-
#casted_hash ⇒ Object
Returns the value of attribute casted_hash.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #cast! ⇒ Object
- #casted? ⇒ Boolean
- #casted_value ⇒ Object
-
#initialize(value, casted_hash) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(value, casted_hash) ⇒ Value
Returns a new instance of Value.
7 8 9 10 |
# File 'lib/casted_hash/value.rb', line 7 def initialize(value, casted_hash) @value = value @casted_hash = casted_hash end |
Instance Attribute Details
#casted_hash ⇒ Object
Returns the value of attribute casted_hash.
5 6 7 |
# File 'lib/casted_hash/value.rb', line 5 def casted_hash @casted_hash end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/casted_hash/value.rb', line 4 def value @value end |
Instance Method Details
#cast! ⇒ Object
21 22 23 24 25 26 |
# File 'lib/casted_hash/value.rb', line 21 def cast! return if casted? @value = casted_hash.cast_proc.call(value) @casted = true end |
#casted? ⇒ Boolean
17 18 19 |
# File 'lib/casted_hash/value.rb', line 17 def casted? !!@casted end |
#casted_value ⇒ Object
12 13 14 15 |
# File 'lib/casted_hash/value.rb', line 12 def casted_value cast! @value end |