Class: Dry::Logic::Rule::Each

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

Instance Attribute Summary

Attributes inherited from Dry::Logic::Rule

#options, #predicate

Instance Method Summary collapse

Methods inherited from Value

#call, #evaluate, #to_ast

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



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

def apply(input)
  Hash[input.map.with_index { |element, index| [index, predicate.(element)] }]
end

#typeObject



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

def type
  :each
end