Class: Definition::Types::Lambda::Conformer

Inherits:
Object
  • Object
show all
Includes:
Dsl
Defined in:
lib/definition/types/lambda.rb

Defined Under Namespace

Modules: Dsl

Instance Method Summary collapse

Methods included from Dsl

#conform_with, #fail_with

Constructor Details

#initialize(definition) ⇒ Conformer

Returns a new instance of Conformer.



36
37
38
# File 'lib/definition/types/lambda.rb', line 36

def initialize(definition)
  @definition = definition
end

Instance Method Details

#conform(value) ⇒ Object



40
41
42
43
44
45
# File 'lib/definition/types/lambda.rb', line 40

def conform(value)
  lambda_result = instance_exec(value, &@definition.conformity_test_lambda)
  return lambda_result if lambda_result.is_a?(ConformResult)

  failure_result_with(value)
end