Class: Diva::Type::OptionalType
Instance Attribute Summary
Attributes inherited from MetaType
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#initialize(type) ⇒ OptionalType
constructor
A new instance of OptionalType.
- #to_s ⇒ Object
Methods inherited from MetaType
Constructor Details
#initialize(type) ⇒ OptionalType
Returns a new instance of OptionalType.
174 175 176 177 |
# File 'lib/diva/type.rb', line 174 def initialize(type) super("optional_#{type.name}") @type = type end |
Instance Method Details
#cast(value) ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/diva/type.rb', line 179 def cast(value) if value.nil? value else @type.cast(value) end end |
#to_s ⇒ Object
187 188 189 |
# File 'lib/diva/type.rb', line 187 def to_s "#{type.to_s}|nil" end |