Module: Dynamoid::IdentityMap

Extended by:
ActiveSupport::Concern
Included in:
Components
Defined in:
lib/dynamoid/identity_map.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) clear



5
6
7
# File 'lib/dynamoid/identity_map.rb', line 5

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

+ (Object) models



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

def self.models
  Dynamoid::Config.included_models
end

Instance Method Details

- (Object) delete



80
81
82
83
84
85
# File 'lib/dynamoid/identity_map.rb', line 80

def delete
  return super if self.class.identity_map_off?

  identity_map.delete(identity_map_key)
  super
end

- (Object) identity_map



67
68
69
# File 'lib/dynamoid/identity_map.rb', line 67

def identity_map
  self.class.identity_map
end

- (Object) identity_map_key



88
89
90
91
92
93
94
# File 'lib/dynamoid/identity_map.rb', line 88

def identity_map_key
  key = hash_key.to_s
  if self.class.range_key
    key += "::#{range_value}"
  end
  key
end

- (Object) save(*args)



71
72
73
74
75
76
77
78
# File 'lib/dynamoid/identity_map.rb', line 71

def save(*args)
  return super if self.class.identity_map_off?

  if result = super
    identity_map[identity_map_key] = self
  end
  result
end