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

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, options=nil)
  self.class.push_uniq({:_id => id}, hash, options)
end

#decrement(args, options = nil) ⇒ Object



132
133
134
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 132

def decrement(args, options=nil)
  self.class.decrement({:_id => id}, _args_for_counter(args), options)
end

#increment(args, options = nil) ⇒ Object



128
129
130
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 128

def increment(args, options=nil)
  self.class.increment({:_id => id}, _args_for_counter(args), options)
end

#pop(hash, options = nil) ⇒ Object



167
168
169
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 167

def pop(hash, options=nil)
  self.class.pop({:_id => id}, hash, options)
end

#pull(hash, options = nil) ⇒ Object



154
155
156
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 154

def pull(hash, options=nil)
  self.class.pull({:_id => id}, hash, options)
end

#pull_all(hash, options = nil) ⇒ Object



158
159
160
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 158

def pull_all(hash, options=nil)
  self.class.pull_all({:_id => id}, hash, options)
end

#push(hash, options = nil) ⇒ Object



140
141
142
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 140

def push(hash, options=nil)
  self.class.push({:_id => id}, hash, options)
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, options=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, options)
end

#set(hash, options = nil) ⇒ Object



136
137
138
# File 'lib/mongo_mapper/plugins/modifiers.rb', line 136

def set(hash, options=nil)
  self.class.set({:_id => id}, hash, options)
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