Method: Hook::Collection#where
- Defined in:
- lib/hook-client/collection.rb
#where(fields = {}, operation = 'and') ⇒ Collection
Add where clause to the current query.
Supported modifiers on fields: .gt, .gte, .lt, .lte, .ne, .in, .not_in, .nin, .like, .between, .not_between
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/hook-client/collection.rb', line 92 def where fields = {}, operation = 'and' fields.each_pair do |k, value| field = (k.respond_to?(:field) ? k.field : k).to_s comparation = k.respond_to?(:comparation) ? k.comparation : '=' # Range syntatic sugar value = [ value.first, value.last ] if value.kind_of?(Range) @wheres << [field, comparation, value, operation] end self end |