Class: Dry::Logic::Predicate
- Inherits:
-
Object
- Object
- Dry::Logic::Predicate
- Defined in:
- lib/dry/logic/predicate.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#fn ⇒ Object
readonly
Returns the value of attribute fn.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #curry(*args) ⇒ Object
-
#initialize(id, *args, &block) ⇒ Predicate
constructor
A new instance of Predicate.
- #to_ary ⇒ Object (also: #to_a)
Constructor Details
#initialize(id, *args, &block) ⇒ Predicate
Returns a new instance of Predicate.
15 16 17 18 19 |
# File 'lib/dry/logic/predicate.rb', line 15 def initialize(id, *args, &block) @id = id @fn = block @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'lib/dry/logic/predicate.rb', line 13 def args @args end |
#fn ⇒ Object (readonly)
Returns the value of attribute fn.
13 14 15 |
# File 'lib/dry/logic/predicate.rb', line 13 def fn @fn end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/dry/logic/predicate.rb', line 13 def id @id end |
Instance Method Details
#call(*args) ⇒ Object
21 22 23 |
# File 'lib/dry/logic/predicate.rb', line 21 def call(*args) fn.(*args) end |
#curry(*args) ⇒ Object
25 26 27 |
# File 'lib/dry/logic/predicate.rb', line 25 def curry(*args) self.class.new(id, *args, &fn.curry.(*args)) end |
#to_ary ⇒ Object Also known as: to_a
29 30 31 |
# File 'lib/dry/logic/predicate.rb', line 29 def to_ary [:predicate, [id, args]] end |