Module: Mycroseconds::CacheKey

Defined in:
lib/mycroseconds/cache_key.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
# File 'lib/mycroseconds/cache_key.rb', line 3

def self.included(base)
  base.class_eval do
    alias_method_chain :cache_key, :precision
  end
end

Instance Method Details

#cache_key_with_precision(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mycroseconds/cache_key.rb', line 9

def cache_key_with_precision(*args)
  value = cache_key_without_precision(*args)

  if !new_record? && precise_updated_at?
    precision = read_attribute_without_precision(:updated_at_precision)
    value << precision.to_s.rjust(6, '0')
  end

  value
end