Class: Dry::Logic::Operations::Abstract

Inherits:
Object
  • Object
show all
Includes:
Core::Constants, Dry::Logic::Operators
Defined in:
lib/dry/logic/operations/abstract.rb

Direct Known Subclasses

Binary, Set, Unary

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dry::Logic::Operators

#and, #or, #then, #xor

Constructor Details

#initialize(*rules, **options) ⇒ Abstract

Returns a new instance of Abstract.



17
18
19
20
# File 'lib/dry/logic/operations/abstract.rb', line 17

def initialize(*rules, **options)
  @rules = rules
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/dry/logic/operations/abstract.rb', line 15

def options
  @options
end

#rulesObject (readonly)

Returns the value of attribute rules.



13
14
15
# File 'lib/dry/logic/operations/abstract.rb', line 13

def rules
  @rules
end

Instance Method Details

#curry(*args) ⇒ Object



26
27
28
# File 'lib/dry/logic/operations/abstract.rb', line 26

def curry(*args)
  new(rules.map { |rule| rule.curry(*args) }, options)
end

#idObject



22
23
24
# File 'lib/dry/logic/operations/abstract.rb', line 22

def id
  options[:id]
end

#new(rules, **new_options) ⇒ Object



30
31
32
# File 'lib/dry/logic/operations/abstract.rb', line 30

def new(rules, **new_options)
  self.class.new(*rules, options.merge(new_options))
end

#to_astObject



38
39
40
# File 'lib/dry/logic/operations/abstract.rb', line 38

def to_ast
  ast
end

#with(new_options) ⇒ Object



34
35
36
# File 'lib/dry/logic/operations/abstract.rb', line 34

def with(new_options)
  new(rules, options.merge(new_options))
end