Class: TwitterFriendly::CacheKey

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_friendly/cache_key.rb

Constant Summary collapse

DELIM =
'__'
VERSION =
'1'

Class Method Summary collapse

Class Method Details

.gen(method_name, args, cache_options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/twitter_friendly/cache_key.rb', line 9

def gen(method_name, args, cache_options = {})
  args_array = args.dup
  options = args_array.extract_options!
  user = method_name == :friendship? ? args_array[0, 2] : args_array[0]

  key =
      [version,
       method_name,
       method_identifier(method_name, user, options, cache_options),
       options_identifier(method_name, options, cache_options)
      ].compact.join(DELIM)

  if ENV['SAVE_CACHE_KEY']
    $last_cache_key = key
    puts key
  end

  key
end