Sha256: 091934aa40ea0d4c80d5abe4db336cacfef637ae6ed464c733ca2926a63a0ec5
Contents?: true
Size: 774 Bytes
Versions: 1
Compression:
Stored size: 774 Bytes
Contents
module PolymorphicUrlCache extend ActiveSupport::Concern included do alias_method_chain :url_for, :cache end URL_FOR_CACHE = {} 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 end ActionView::RoutingUrlFor.include PolymorphicUrlCache
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polymorphic_url_cache-0.0.1 | lib/polymorphic_url_cache.rb |