Module: MongoidExt::Modifiers::ClassMethods

Defined in:
lib/mongoid_ext/modifiers.rb

Instance Method Summary collapse

Instance Method Details

#decrement(conditions, update) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/mongoid_ext/modifiers.rb', line 11

def decrement(conditions, update)
  update.each do |k, v|
    update[k] = -v.abs
  end

  _apply_modifier('$inc', conditions, update)
end

#increment(conditions, update) ⇒ Object



7
8
9
# File 'lib/mongoid_ext/modifiers.rb', line 7

def increment(conditions, update)
  _apply_modifier('$inc', conditions, update)
end

#override(conditions, update) ⇒ Object

set() is already taken :(



19
20
21
# File 'lib/mongoid_ext/modifiers.rb', line 19

def override(conditions, update) # set() is already taken :(
  _apply_modifier('$set', conditions, update)
end

#pop(conditions, update) ⇒ Object



47
48
49
# File 'lib/mongoid_ext/modifiers.rb', line 47

def pop(conditions, update)
  _apply_modifier('$pop', conditions, update)
end

#pull(conditions, update) ⇒ Object



39
40
41
# File 'lib/mongoid_ext/modifiers.rb', line 39

def pull(conditions, update)
  _apply_modifier('$pull', conditions, update)
end

#pull_all(conditions, update) ⇒ Object



43
44
45
# File 'lib/mongoid_ext/modifiers.rb', line 43

def pull_all(conditions, update)
  _apply_modifier('$pullAll', conditions, update)
end

#push(conditions, update) ⇒ Object



27
28
29
# File 'lib/mongoid_ext/modifiers.rb', line 27

def push(conditions, update)
  _apply_modifier('$push', conditions, update)
end

#push_all(conditions, update) ⇒ Object



31
32
33
# File 'lib/mongoid_ext/modifiers.rb', line 31

def push_all(conditions, update)
  _apply_modifier('$pushAll', conditions, update)
end

#push_uniq(conditions, update) ⇒ Object



35
36
37
# File 'lib/mongoid_ext/modifiers.rb', line 35

def push_uniq(conditions, update)
  _apply_modifier('$addToSet', conditions, update)
end

#unset(conditions, update) ⇒ Object



23
24
25
# File 'lib/mongoid_ext/modifiers.rb', line 23

def unset(conditions, update)
  _apply_modifier('$unset', conditions, update)
end