Module: Mongoid::Contextual::Atomic
- Defined in:
- lib/patches/atomic.rb
Instance Method Summary collapse
- #add_to_set_with_mongoid4(*args) ⇒ Object
- #bit_with_mongoid4(*args) ⇒ Object
- #inc_with_mongoid4(*args) ⇒ Object
- #pop_with_mongoid4(*args) ⇒ Object
- #pull_all_with_mongoid4(*args) ⇒ Object
- #pull_with_mongoid4(*args) ⇒ Object
- #push_all_with_mongoid4(*args) ⇒ Object
- #push_with_mongoid4(*args) ⇒ Object
- #rename_with_mongoid4(*args) ⇒ Object
- #set_with_mongoid4(*args) ⇒ Object
Instance Method Details
#add_to_set_with_mongoid4(*args) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/patches/atomic.rb', line 9 def add_to_set_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$addToSet" => collect_operations(args.first)) else add_to_set_without_mongoid4(*args) end end |
#bit_with_mongoid4(*args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/patches/atomic.rb', line 18 def bit_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$bit" => collect_operations(args.first)) else bit_without_mongoid4(*args) end end |
#inc_with_mongoid4(*args) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/patches/atomic.rb', line 27 def inc_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$inc" => collect_operations(args.first)) else inc_without_mongoid4(*args) end end |
#pop_with_mongoid4(*args) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/patches/atomic.rb', line 36 def pop_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$pop" => collect_operations(args.first)) else pop_without_mongoid4(*args) end end |
#pull_all_with_mongoid4(*args) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/patches/atomic.rb', line 54 def pull_all_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$pullAll" => collect_operations(args.first)) else pull_all_without_mongoid4(*args) end end |
#pull_with_mongoid4(*args) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/patches/atomic.rb', line 45 def pull_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$pull" => collect_operations(args.first)) else pull_without_mongoid4(*args) end end |
#push_all_with_mongoid4(*args) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/patches/atomic.rb', line 72 def push_all_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$pushAll" => collect_operations(args.first)) else push_all_without_mongoid4(*args) end end |
#push_with_mongoid4(*args) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/patches/atomic.rb', line 63 def push_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$push" => collect_operations(args.first)) else push_without_mongoid4(*args) end end |
#rename_with_mongoid4(*args) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/patches/atomic.rb', line 81 def rename_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) operations = args.first.inject({}) do |ops, (old_name, new_name)| ops[old_name] = new_name.to_s ops end query.update_all("$rename" => collect_operations(operations)) else rename_without_mongoid4(*args) end end |
#set_with_mongoid4(*args) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/patches/atomic.rb', line 94 def set_with_mongoid4(*args) if args.length == 1 && args.first.is_a?(Hash) query.update_all("$set" => collect_operations(args.first)) else set_without_mongoid4(*args) end end |