Class: Dry::Logic::Rule::Predicate

Inherits:
Dry::Logic::Rule show all
Defined in:
lib/dry/logic/rule/predicate.rb

Instance Attribute Summary

Attributes inherited from Dry::Logic::Rule

#args, #arity, #options, #predicate

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dry::Logic::Rule

#bind, build, #curry, #eval_args, #id, #initialize, interfaces, #parameters, #with

Methods included from Operators

#and, #or, #then, #xor

Constructor Details

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

Class Method Details

.specialize(arity, curried, base = Predicate) ⇒ Object



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

def self.specialize(arity, curried, base = Predicate)
  super
end

Instance Method Details

#ast(input = Undefined) ⇒ Object Also known as: to_ast



28
29
30
# File 'lib/dry/logic/rule/predicate.rb', line 28

def ast(input = Undefined)
  [type, [name, args_with_names(input)]]
end

#nameObject



16
17
18
# File 'lib/dry/logic/rule/predicate.rb', line 16

def name
  predicate.name
end

#to_sObject



20
21
22
23
24
25
26
# File 'lib/dry/logic/rule/predicate.rb', line 20

def to_s
  if args.size > 0
    "#{name}(#{args.map(&:inspect).join(', ')})"
  else
    "#{name}"
  end
end

#typeObject



12
13
14
# File 'lib/dry/logic/rule/predicate.rb', line 12

def type
  :predicate
end