module Might::FilterPredicates
Contains contains with all supported predicates You can register your own predicates. Predicates should perform on array or on singular value:
Might::FilterPredicates.register('includes', on: :array) Might::FilterPredicates.register('is_upper_case', on: :value)
Constants
- BLANK
- CONT
- CONT_ANY
- DOES_NOT_END
- DOES_NOT_MATCH
- ENDS
- EQ
- FALSE
- GT
- GTEQ
- IN
- LT
- LTEQ
- MATCHES
- NOT_CONT
- NOT_CONT_ANY
- NOT_EQ
- NOT_FALSE
- NOT_IN
- NOT_NULL
- NOT_START
- NOT_TRUE
- NULL
- PRESENT
- START
- TRUE
Public Class Methods
all()
click to toggle source
Returns all predicates @return [Set<String>]
# File lib/might/filter_predicates.rb, line 92 def all @predicates_on_value + @predicates_on_array end
array()
click to toggle source
Returns predicates for array @return [Set<String>]
# File lib/might/filter_predicates.rb, line 76 def array @predicates_on_array.dup end
register(predicate, on:)
click to toggle source
Registers predicate on singular value or on array @param predicate [String, Symbol] @param on [:array, :value] @return [Might::FilterPredicates]
# File lib/might/filter_predicates.rb, line 60 def register(predicate, on:) case on when :value @predicates_on_value.add(predicate.to_s) when :array @predicates_on_array.add(predicate.to_s) else fail ArgumentError, 'on must be :array, or :value' end self end
value()
click to toggle source
Returns predicates for values @return [Set<String>]
# File lib/might/filter_predicates.rb, line 84 def value @predicates_on_value.dup end
Private Instance Methods
all()
click to toggle source
Returns all predicates @return [Set<String>]
# File lib/might/filter_predicates.rb, line 92 def all @predicates_on_value + @predicates_on_array end
array()
click to toggle source
Returns predicates for array @return [Set<String>]
# File lib/might/filter_predicates.rb, line 76 def array @predicates_on_array.dup end
register(predicate, on:)
click to toggle source
Registers predicate on singular value or on array @param predicate [String, Symbol] @param on [:array, :value] @return [Might::FilterPredicates]
# File lib/might/filter_predicates.rb, line 60 def register(predicate, on:) case on when :value @predicates_on_value.add(predicate.to_s) when :array @predicates_on_array.add(predicate.to_s) else fail ArgumentError, 'on must be :array, or :value' end self end
value()
click to toggle source
Returns predicates for values @return [Set<String>]
# File lib/might/filter_predicates.rb, line 84 def value @predicates_on_value.dup end