Module: EmptyEye::Persistence

Included in:
ActiveRecord::Base
Defined in:
lib/empty_eye/persistence.rb

Instance Method Summary collapse

Instance Method Details

#createObject

if it is not a mti_class do what you do else let the primary shard do the saving come back and cleanup



15
16
17
18
19
20
21
# File 'lib/empty_eye/persistence.rb', line 15

def create
  return super unless mti_class?
  shard_wrangler.cascade_save
  ActiveRecord::IdentityMap.add(self) if ActiveRecord::IdentityMap.enabled?
  @new_record = false
  self.id
end

#deleteObject

if it is not a mti_class do what you do else let the primary shard do the deletion come back and cleanup



39
40
41
42
43
44
45
46
47
# File 'lib/empty_eye/persistence.rb', line 39

def delete
  return super unless mti_class?
  shard_wrangler.class.cascade_delete_all(:id => id)
  if ActiveRecord::IdentityMap.enabled? and persisted?
    ActiveRecord::IdentityMap.remove(self)
  end
  @destroyed = true
  freeze
end

#destroyObject

if it is not a mti_class do what you do else let the primary shard do the destruction come back and cleanup



26
27
28
29
30
31
32
33
34
# File 'lib/empty_eye/persistence.rb', line 26

def destroy
  return super unless mti_class?
  shard_wrangler.destroy
  if ActiveRecord::IdentityMap.enabled? and persisted?
    ActiveRecord::IdentityMap.remove(self)
  end
  @destroyed = true
  freeze
end

#update(attribute_names = @attributes.keys) ⇒ Object

if it is not a mti_class do what you do else let the primary shard do the saving



6
7
8
9
10
# File 'lib/empty_eye/persistence.rb', line 6

def update(attribute_names = @attributes.keys)
  return super unless mti_class?
  shard_wrangler.cascade_save
  1
end