Class: Dry::Logic::Rule::Value

Inherits:
Dry::Logic::Rule show all
Defined in:
lib/dry/logic/rule/value.rb

Direct Known Subclasses

Check, Each, Key, Negation, Set

Instance Attribute Summary

Attributes inherited from Dry::Logic::Rule

#options, #predicate

Instance Method Summary collapse

Methods inherited from Dry::Logic::Rule

#and, #curry, #each?, #initialize, #negation, #new, #or, #predicate_id, #then, #xor

Constructor Details

This class inherits a constructor from Dry::Logic::Rule

Instance Method Details

#apply(input) ⇒ Object



12
13
14
# File 'lib/dry/logic/rule/value.rb', line 12

def apply(input)
  predicate.(evaluate(input))
end

#call(input) ⇒ Object



8
9
10
# File 'lib/dry/logic/rule/value.rb', line 8

def call(input)
  Logic.Result(apply(input), self, input)
end

#evaluate(input) ⇒ Object



16
17
18
# File 'lib/dry/logic/rule/value.rb', line 16

def evaluate(input)
  input
end

#to_astObject



20
21
22
# File 'lib/dry/logic/rule/value.rb', line 20

def to_ast
  [type, predicate.to_ast]
end

#typeObject



4
5
6
# File 'lib/dry/logic/rule/value.rb', line 4

def type
  :val
end