Module: MongoMapper::Plugins::Modifiers
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document
- Defined in:
- lib/mongo_mapper/plugins/modifiers.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #add_to_set(hash, options = nil) ⇒ Object (also: #push_uniq)
- #decrement(args, options = nil) ⇒ Object
- #increment(args, options = nil) ⇒ Object
- #pop(hash, options = nil) ⇒ Object
- #pull(hash, options = nil) ⇒ Object
- #pull_all(hash, options = nil) ⇒ Object
- #push(hash, options = nil) ⇒ Object
- #push_all(hash, options = nil) ⇒ Object
- #set(hash, options = nil) ⇒ Object
- #unset(*args) ⇒ Object
Instance Method Details
#add_to_set(hash, options = nil) ⇒ Object Also known as: push_uniq
162 163 164 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 162 def add_to_set(hash, =nil) self.class.push_uniq({:_id => id}, hash, ) end |
#decrement(args, options = nil) ⇒ Object
132 133 134 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 132 def decrement(args, =nil) self.class.decrement({:_id => id}, _args_for_counter(args), ) end |
#increment(args, options = nil) ⇒ Object
128 129 130 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 128 def increment(args, =nil) self.class.increment({:_id => id}, _args_for_counter(args), ) end |
#pop(hash, options = nil) ⇒ Object
167 168 169 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 167 def pop(hash, =nil) self.class.pop({:_id => id}, hash, ) end |
#pull(hash, options = nil) ⇒ Object
154 155 156 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 154 def pull(hash, =nil) self.class.pull({:_id => id}, hash, ) end |
#pull_all(hash, options = nil) ⇒ Object
158 159 160 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 158 def pull_all(hash, =nil) self.class.pull_all({:_id => id}, hash, ) end |
#push(hash, options = nil) ⇒ Object
140 141 142 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 140 def push(hash, =nil) self.class.push({:_id => id}, hash, ) end |
#push_all(hash, options = nil) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 144 def push_all(hash, =nil) Kernel.warn "push_all no longer supported. use $push with $each" push_values = hash.inject({}) do |hsh, (key, values)| { key => { '$each' => values } } end self.class.push({:_id => id}, push_values, ) end |
#set(hash, options = nil) ⇒ Object
136 137 138 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 136 def set(hash, =nil) self.class.set({:_id => id}, hash, ) end |
#unset(*args) ⇒ Object
124 125 126 |
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 124 def unset(*args) self.class.unset({:_id => id}, *args) end |