Class: Dry::Logic::Rule::Set

Inherits:
Value show all
Defined in:
lib/dry/logic/rule/set.rb

Instance Attribute Summary

Attributes inherited from Dry::Logic::Rule

#options, #predicate

Instance Method Summary collapse

Methods inherited from Value

#call, #evaluate

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



10
11
12
# File 'lib/dry/logic/rule/set.rb', line 10

def apply(input)
  rules.map { |rule| rule.(input) }
end

#at(*args) ⇒ Object



14
15
16
# File 'lib/dry/logic/rule/set.rb', line 14

def at(*args)
  new(rules.values_at(*args))
end

#to_astObject



18
19
20
# File 'lib/dry/logic/rule/set.rb', line 18

def to_ast
  [type, rules.map { |rule| rule.to_ast }]
end

#typeObject



6
7
8
# File 'lib/dry/logic/rule/set.rb', line 6

def type
  :set
end