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.



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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#rulesObject (readonly)

Returns the value of attribute rules.



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

def rules
  @rules
end

Instance Method Details

#curry(*args) ⇒ Object



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

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

#idObject



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

def id
  options[:id]
end

#new(rules, **new_options) ⇒ Object



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

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

#to_astObject



40
41
42
# File 'lib/dry/logic/operations/abstract.rb', line 40

def to_ast
  ast
end

#with(new_options) ⇒ Object



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

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