Module: Axiom::Function::Predicate::Enumerable
Overview
A mixin for predicates matching an enumerable
Class Method Summary collapse
-
.compare_method(enumerable) ⇒ Symbol
private
Return the method to test the enumerable with.
Instance Method Summary collapse
-
#call(tuple) ⇒ Boolean
Evaluate the enumerable function using the tuple.
-
#initialize(left, right) ⇒ undefined
private
Initialize an Enumerable predicate.
Class Method Details
.compare_method(enumerable) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the method to test the enumerable with
17 18 19 |
# File 'lib/axiom/function/predicate/enumerable.rb', line 17 def self.compare_method(enumerable) enumerable.respond_to?(:cover?) ? :cover? : :include? end |
Instance Method Details
#call(tuple) ⇒ Boolean
Evaluate the enumerable function using the tuple
46 47 48 49 50 51 52 |
# File 'lib/axiom/function/predicate/enumerable.rb', line 46 def call(tuple) util = self.class util.call( util.extract_value(left, tuple), right.map { |entry| util.extract_value(entry, tuple) } ) end |
#initialize(left, right) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize an Enumerable predicate
31 32 33 |
# File 'lib/axiom/function/predicate/enumerable.rb', line 31 def initialize(left, right) super(left, freeze_object(right)) end |