Class: Definition::Types::Or::Conformer
- Inherits:
-
Object
- Object
- Definition::Types::Or::Conformer
- Defined in:
- lib/definition/types/or.rb
Instance Method Summary collapse
- #conform(value) ⇒ Object
-
#initialize(definition) ⇒ Conformer
constructor
A new instance of Conformer.
Constructor Details
#initialize(definition) ⇒ Conformer
Returns a new instance of Conformer.
27 28 29 |
# File 'lib/definition/types/or.rb', line 27 def initialize(definition) self.definition = definition end |
Instance Method Details
#conform(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/definition/types/or.rb', line 31 def conform(value) result = first_successful_conform_or_errors(value) if result.is_a?(ConformResult) result else error = ConformError.new(definition, "None of the definitions are valid for #{definition.name}", sub_errors: result) ConformResult.new(value, errors: [error]) end end |