Class: FilterFactory::Mongoid::Condition
- Inherits:
-
Condition
- Object
- Condition
- FilterFactory::Mongoid::Condition
show all
- Defined in:
- lib/filter_factory/mongoid/condition.rb
Instance Attribute Summary
Attributes inherited from Condition
#field_name, #value
Instance Method Summary
collapse
Methods inherited from Condition
#initialize
Instance Method Details
#all(obj) ⇒ Object
28
29
30
|
# File 'lib/filter_factory/mongoid/condition.rb', line 28
def all(obj)
obj.where(field_name => { '$all' => value })
end
|
#eq(obj) ⇒ Object
4
5
6
|
# File 'lib/filter_factory/mongoid/condition.rb', line 4
def eq(obj)
obj.where(field_name => value)
end
|
#exists(obj) ⇒ Object
44
45
46
|
# File 'lib/filter_factory/mongoid/condition.rb', line 44
def exists(obj)
obj.where(field_name => { '$exists' => value })
end
|
#gt(obj) ⇒ Object
20
21
22
|
# File 'lib/filter_factory/mongoid/condition.rb', line 20
def gt(obj)
obj.where(field_name => { '$gt' => value })
end
|
#gte(obj) ⇒ Object
24
25
26
|
# File 'lib/filter_factory/mongoid/condition.rb', line 24
def gte(obj)
obj.where(field_name => { '$gte' => value })
end
|
#in(obj) ⇒ Object
32
33
34
|
# File 'lib/filter_factory/mongoid/condition.rb', line 32
def in(obj)
obj.where(field_name => { '$in' => value })
end
|
#lt(obj) ⇒ Object
12
13
14
|
# File 'lib/filter_factory/mongoid/condition.rb', line 12
def lt(obj)
obj.where(field_name => { '$lt' => value })
end
|
#lte(obj) ⇒ Object
16
17
18
|
# File 'lib/filter_factory/mongoid/condition.rb', line 16
def lte(obj)
obj.where(field_name => { '$lte' => value })
end
|
#ne(obj) ⇒ Object
8
9
10
|
# File 'lib/filter_factory/mongoid/condition.rb', line 8
def ne(obj)
obj.where(field_name => { '$ne' => value })
end
|
#nin(obj) ⇒ Object
36
37
38
|
# File 'lib/filter_factory/mongoid/condition.rb', line 36
def nin(obj)
obj.where(field_name => { '$nin' => value })
end
|
#presents(obj) ⇒ Object
48
49
50
51
|
# File 'lib/filter_factory/mongoid/condition.rb', line 48
def presents(obj)
operator = ['true', '1', 1].include?(value) ? '$nin' : '$in'
obj.where(field_name => { operator => [nil, '', []] })
end
|
#regex(obj) ⇒ Object
40
41
42
|
# File 'lib/filter_factory/mongoid/condition.rb', line 40
def regex(obj)
obj.where(field_name => /#{Regexp.escape(value)}/)
end
|