Class: Definition::Types::Lambda
- Includes:
- Dsl
- Defined in:
- lib/definition/types/lambda.rb
Defined Under Namespace
Modules: Dsl
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #conform(value) ⇒ Object
-
#initialize(name, &test_lambda) ⇒ Lambda
constructor
A new instance of Lambda.
Methods included from Dsl
Methods inherited from Base
Constructor Details
#initialize(name, &test_lambda) ⇒ Lambda
Returns a new instance of Lambda.
15 16 17 18 |
# File 'lib/definition/types/lambda.rb', line 15 def initialize(name, &test_lambda) self.test_lambda = test_lambda super(name) end |
Instance Method Details
#conform(value) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/definition/types/lambda.rb', line 20 def conform(value) lambda_result = instance_exec(value, &test_lambda) return lambda_result if lambda_result.is_a?(ConformResult) ConformResult.new(value, errors: [ ConformError.new(self, "Did not pass test for #{name}") ]) end |