Class: Dry::Logic::Result::Set

Inherits:
Dry::Logic::Result show all
Defined in:
lib/dry/logic/result.rb

Instance Attribute Summary

Attributes inherited from Dry::Logic::Result

#input, #name, #rule, #value

Instance Method Summary collapse

Methods inherited from Dry::Logic::Result

#>, #and, #call, #curry, #failure?, #initialize, #negated, #or, #xor

Constructor Details

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

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/dry/logic/result.rb', line 17

def success?
  value.all?(&:success?)
end

#to_aryObject



21
22
23
24
# File 'lib/dry/logic/result.rb', line 21

def to_ary
  indices = value.map { |v| v.failure? ? value.index(v) : nil }.compact
  [:input, [rule.name, input, value.values_at(*indices).map(&:to_ary)]]
end