Class: WorkflowTemplate::Validation::Evaluation::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow_template/validation/evaluation/abstract.rb

Direct Known Subclasses

Boolean, Canonical

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, key, context, validator) ⇒ Abstract

Returns a new instance of Abstract.



16
17
18
19
20
21
22
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 16

def initialize(name, key, context, validator)
  @name = name.to_sym
  @key = key&.to_sym
  @context = context.freeze
  @validator = validator
  freeze
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



14
15
16
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 14

def context
  @context
end

#keyObject (readonly)

Returns the value of attribute key.



14
15
16
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 14

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 14

def name
  @name
end

#validatorObject (readonly)

Returns the value of attribute validator.



14
15
16
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 14

def validator
  @validator
end

Instance Method Details

#call(data) ⇒ Object



24
25
26
27
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 24

def call(data)
  result = run_validator(data)
  evaluate(result)
end

#describeObject



33
34
35
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 33

def describe
  validator.describe
end

#evaluate(_result) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/workflow_template/validation/evaluation/abstract.rb', line 29

def evaluate(_result)
  raise NotImplementedError, "#{self.class.name}##{__method__} unimplemented"
end