Class: Dry::Logic::Operations::Set
Instance Attribute Summary
Attributes inherited from Abstract
#options, #rules
Instance Method Summary
collapse
Methods inherited from Abstract
#curry, #id, #initialize, #new, #to_ast, #with
#and, #or, #then, #xor
Instance Method Details
#[](input) ⇒ Object
21
22
23
|
# File 'lib/dry/logic/operations/set.rb', line 21
def [](input)
rules.map { |rule| rule[input] }.all?
end
|
#ast(input = Undefined) ⇒ Object
25
26
27
|
# File 'lib/dry/logic/operations/set.rb', line 25
def ast(input = Undefined)
[type, rules.map { |rule| rule.ast(input) }]
end
|
#call(input) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/dry/logic/operations/set.rb', line 12
def call(input)
results = rules.map { |rule| rule.(input) }
success = results.all?(&:success?)
Result.new(success, id) do
[type, results.select(&:failure?).map { |failure| failure.to_ast }]
end
end
|
#to_s ⇒ Object
29
30
31
|
# File 'lib/dry/logic/operations/set.rb', line 29
def to_s
"#{type}(#{rules.map(&:to_s).join(', ')})"
end
|
#type ⇒ Object
8
9
10
|
# File 'lib/dry/logic/operations/set.rb', line 8
def type
:set
end
|