Class: StrongCSV::Types::Optional
- Defined in:
- lib/strong_csv/types/optional.rb
Overview
Optional type
Instance Method Summary collapse
- #cast(value) ⇒ ValueResult
-
#initialize(type) ⇒ Optional
constructor
A new instance of Optional.
Constructor Details
#initialize(type) ⇒ Optional
Returns a new instance of Optional.
10 11 12 13 |
# File 'lib/strong_csv/types/optional.rb', line 10 def initialize(type) super() @type = type end |
Instance Method Details
#cast(value) ⇒ ValueResult
17 18 19 |
# File 'lib/strong_csv/types/optional.rb', line 17 def cast(value) value.nil? ? ValueResult.new(value: nil, original_value: value) : @type.cast(value) end |