Module: Might::FilterPredicates
- Defined in:
- lib/might/filter_predicates.rb
Overview
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)
Constant Summary collapse
- NOT_EQ =
'not_eq'- EQ =
'eq'- DOES_NOT_MATCH =
'does_not_match'- MATCHES =
'matches'- GT =
'gt'- LT =
'lt'- GTEQ =
'gteq'- LTEQ =
'lteq'- NOT_CONT =
'not_cont'- CONT =
'cont'- NOT_START =
'not_start'- START =
'start'- DOES_NOT_END =
'not_end'- ENDS =
'end'- NOT_TRUE =
'not_true'- TRUE =
'true'- NOT_FALSE =
'not_false'- FALSE =
'false'- BLANK =
'blank'- PRESENT =
'present'- NOT_NULL =
'not_null'- NULL =
'null'- NOT_IN =
'not_in'- IN =
'in'- NOT_CONT_ANY =
'not_cont_any'- CONT_ANY =
'cont_any'
Class Method Summary collapse
-
.all ⇒ Set<String>
Returns all predicates.
-
.array ⇒ Set<String>
Returns predicates for array.
-
.register(predicate, on:) ⇒ Might::FilterPredicates
Registers predicate on singular value or on array.
-
.value ⇒ Set<String>
Returns predicates for values.
Class Method Details
.all ⇒ Set<String>
Returns all predicates
92 93 94 |
# File 'lib/might/filter_predicates.rb', line 92 def all @predicates_on_value + @predicates_on_array end |
.array ⇒ Set<String>
Returns predicates for array
76 77 78 |
# File 'lib/might/filter_predicates.rb', line 76 def array @predicates_on_array.dup end |
.register(predicate, on:) ⇒ Might::FilterPredicates
Registers predicate on singular value or on array
60 61 62 63 64 65 66 67 68 69 70 |
# 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 ⇒ Set<String>
Returns predicates for values
84 85 86 |
# File 'lib/might/filter_predicates.rb', line 84 def value @predicates_on_value.dup end |