Module: Sequel::Unicache::Hook::InstanceMethods

Defined in:
lib/sequel/unicache/hook.rb

Instance Method Summary collapse

Instance Method Details

#after_commitObject



13
14
15
16
17
18
19
# File 'lib/sequel/unicache/hook.rb', line 13

def after_commit
  if Unicache.enabled?
    Write.expire self
    @_unicache_previous_values = nil
  end
  super
end

#after_destroy_commitObject



26
27
28
29
30
31
32
# File 'lib/sequel/unicache/hook.rb', line 26

def after_destroy_commit
  if Unicache.enabled?
    Write.expire self
    @_unicache_previous_values = nil
  end
  super
end

#after_destroy_rollbackObject



34
35
36
37
# File 'lib/sequel/unicache/hook.rb', line 34

def after_destroy_rollback
  @_unicache_previous_values = nil if Unicache.enabled?
  super
end

#after_rollbackObject



21
22
23
24
# File 'lib/sequel/unicache/hook.rb', line 21

def after_rollback
  @_unicache_previous_values = nil if Unicache.enabled?
  super
end

#before_destroyObject



39
40
41
42
43
44
# File 'lib/sequel/unicache/hook.rb', line 39

def before_destroy
  if Unicache.enabled? && !Write.check_completeness?(self) && primary_key
    @_unicache_previous_values = self.class.with_pk(pk).values
  end
  super
end

#before_updateObject



46
47
48
49
50
51
52
# File 'lib/sequel/unicache/hook.rb', line 46

def before_update
  if Unicache.enabled?
    # Store all previous values, to be expired
    @_unicache_previous_values = initial_values.merge(@_unicache_previous_values || {})
  end
  super
end