Class: Definition::Types::And
- Includes:
- Dsl
- Defined in:
- lib/definition/types/and.rb
Defined Under Namespace
Modules: Dsl
Instance Attribute Summary collapse
-
#definitions ⇒ Object
Returns the value of attribute definitions.
Attributes inherited from Base
Instance Method Summary collapse
- #conform(value) ⇒ Object
- #error_renderer ⇒ Object
-
#initialize(name, *args) ⇒ And
constructor
A new instance of And.
Methods included from Dsl
Methods inherited from Base
Constructor Details
#initialize(name, *args) ⇒ And
Returns a new instance of And.
18 19 20 21 |
# File 'lib/definition/types/and.rb', line 18 def initialize(name, *args) self.definitions = *args super(name) end |
Instance Attribute Details
#definitions ⇒ Object
Returns the value of attribute definitions.
16 17 18 |
# File 'lib/definition/types/and.rb', line 16 def definitions @definitions end |
Instance Method Details
#conform(value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/definition/types/and.rb', line 23 def conform(value) last_result = nil definitions.each do |definition| last_result = definition.conform(last_result.nil? ? value : last_result.value) next if last_result.passed? return ConformResult.new(last_result.value, errors: [ ConformError.new(self, "Not all definitions are valid for '#{name}'", sub_errors: last_result.error_tree) ]) end ConformResult.new(last_result.value) end |
#error_renderer ⇒ Object
38 39 40 |
# File 'lib/definition/types/and.rb', line 38 def error_renderer ErrorRenderers::Leaf end |