9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/polymorphic_url_cache.rb', line 9
def url_for_with_cache(options = nil)
key = case options
when ActiveRecord::Base
[options.class, options.to_param]
when Array
return url_for_without_cache(options) if options.none? {|o| o.is_a? ActiveRecord::Base}
options.each_with_object([]) do |o, k|
if o.is_a? ActiveRecord::Base
k << [options.class, options.to_param]
else
k << o
end
end
else
return url_for_without_cache(options)
end
URL_FOR_CACHE[key] || (URL_FOR_CACHE[key] = url_for_without_cache(options))
end
|