Module: ClassyFilter::Predicates
Instance Method Summary collapse
- #contains(ds, attribute, input) ⇒ Object
- #contains_i(ds, attribute, input) ⇒ Object
- #eq_in(ds, attribute, input) ⇒ Object (also: #eq, #in)
-
#gt(ds, attribute, input) ⇒ Object
TODO: think about refactoring.
- #gteq(ds, attribute, input) ⇒ Object
- #lt(ds, attribute, input) ⇒ Object
- #lteq(ds, attribute, input) ⇒ Object
- #starts_with(ds, attribute, input) ⇒ Object
- #starts_with_i(ds, attribute, input) ⇒ Object
Instance Method Details
#contains(ds, attribute, input) ⇒ Object
38 39 40 |
# File 'lib/classy_filter/predicates.rb', line 38 def contains(ds, attribute, input) ds.where { |_r| Sequel.like(sequel_col(ds, attribute), "%#{input}%") } end |
#contains_i(ds, attribute, input) ⇒ Object
42 43 44 |
# File 'lib/classy_filter/predicates.rb', line 42 def contains_i(ds, attribute, input) ds.where { |_r| Sequel.ilike(sequel_col(ds, attribute), "%#{input}%") } end |
#eq_in(ds, attribute, input) ⇒ Object Also known as: eq, in
5 6 7 |
# File 'lib/classy_filter/predicates.rb', line 5 def eq_in(ds, attribute, input) ds.where(attribute => input) end |
#gt(ds, attribute, input) ⇒ Object
TODO: think about refactoring
14 15 16 |
# File 'lib/classy_filter/predicates.rb', line 14 def gt(ds, attribute, input) ds.where { |_r| sequel_col(ds, attribute) > input } end |
#gteq(ds, attribute, input) ⇒ Object
22 23 24 |
# File 'lib/classy_filter/predicates.rb', line 22 def gteq(ds, attribute, input) ds.where { |_r| sequel_col(ds, attribute) >= input } end |
#lt(ds, attribute, input) ⇒ Object
18 19 20 |
# File 'lib/classy_filter/predicates.rb', line 18 def lt(ds, attribute, input) ds.where { |_r| sequel_col(ds, attribute) < input } end |
#lteq(ds, attribute, input) ⇒ Object
26 27 28 |
# File 'lib/classy_filter/predicates.rb', line 26 def lteq(ds, attribute, input) ds.where { |_r| sequel_col(ds, attribute) <= input } end |
#starts_with(ds, attribute, input) ⇒ Object
30 31 32 |
# File 'lib/classy_filter/predicates.rb', line 30 def starts_with(ds, attribute, input) ds.where { |_r| Sequel.like(sequel_col(ds, attribute), input + '%') } end |
#starts_with_i(ds, attribute, input) ⇒ Object
34 35 36 |
# File 'lib/classy_filter/predicates.rb', line 34 def starts_with_i(ds, attribute, input) ds.where { |_r| Sequel.ilike(sequel_col(ds, attribute), input + '%') } end |