Module: MongoMapper::Plugins::IdentityMap

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongo_mapper/plugins/identity_map.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clearObject



13
14
15
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 13

def self.clear
  models.each { |m| m.identity_map.clear }
end

.modelsObject



9
10
11
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 9

def self.models
  @models ||= Set.new
end

Instance Method Details

#deleteObject



122
123
124
125
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 122

def delete
  identity_map.delete(_id) if self.class.identity_map_on?
  super
end

#identity_mapObject



111
112
113
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 111

def identity_map
  self.class.identity_map
end

#save(*args) ⇒ Object



115
116
117
118
119
120
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 115

def save(*args)
  if result = super
    identity_map[_id] = self if self.class.identity_map_on?
  end
  result
end