Class: Definition::Types::Type
- Defined in:
- lib/definition/types/type.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #conform(value) ⇒ Object
-
#initialize(name, klass, &coerce) ⇒ Type
constructor
A new instance of Type.
Methods inherited from Base
Constructor Details
#initialize(name, klass, &coerce) ⇒ Type
Returns a new instance of Type.
8 9 10 11 12 |
# File 'lib/definition/types/type.rb', line 8 def initialize(name, klass, &coerce) self.klass = klass self.coerce = coerce super(name) end |
Instance Method Details
#conform(value) ⇒ Object
14 15 16 17 18 |
# File 'lib/definition/types/type.rb', line 14 def conform(value) value = coerce.call(value) if coerce && !valid?(value) try_conform(value) end |