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.



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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#rulesObject (readonly)

Returns the value of attribute rules.



11
12
13
# File 'lib/dry/logic/operations/abstract.rb', line 11

def rules
  @rules
end

Instance Method Details

#curry(*args) ⇒ Object



24
25
26
# File 'lib/dry/logic/operations/abstract.rb', line 24

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

#idObject



20
21
22
# File 'lib/dry/logic/operations/abstract.rb', line 20

def id
  options[:id]
end

#new(rules, **new_options) ⇒ Object



28
29
30
# File 'lib/dry/logic/operations/abstract.rb', line 28

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

#to_astObject



36
37
38
# File 'lib/dry/logic/operations/abstract.rb', line 36

def to_ast
  ast
end

#with(new_options) ⇒ Object



32
33
34
# File 'lib/dry/logic/operations/abstract.rb', line 32

def with(new_options)
  new(rules, **options, **new_options)
end