Module: Stale::Model

Defined in:
lib/stale/model.rb

Constant Summary collapse

IDENTIFIER =
:stale_key

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/stale/model.rb', line 5

def self.included(base)
  base.class_eval do
    after_commit :expire_stale_dependencies if respond_to?(:after_commit)
  end
end

Instance Method Details

#expire_stale_dependenciesObject



19
20
21
# File 'lib/stale/model.rb', line 19

def expire_stale_dependencies
  Stale.interface.expire_dependencies(stale_key)
end

#stale_idObject



11
12
13
# File 'lib/stale/model.rb', line 11

def stale_id
  to_param
end

#stale_keyObject



15
16
17
# File 'lib/stale/model.rb', line 15

def stale_key
  Stale.interface.key_for_model(self.class, stale_id)
end