Sha256: 70888bc9b81f506b73a4a9fd2c7c2a5cd9fa7552b7dd730151516a1f81997abd
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
module Catche module Controller module Base extend ActiveSupport::Concern included do class_attribute :catche_model, :catche_resource_name end module ClassMethods # Caches a controller action by tagging it. # Supports any option parameters caches_action supports. # # catche Project, :index, :resource_name => :project def catche(model, *args) options = args.extract_options! self.catche_model = model self.catche_resource_name = options[:resource_name] || self.catche_model.name.downcase.to_sym # Use Rails caches_action to pass along the tag caches_action(*args, options.merge({ :catche => true })) end end def catche_tags return @catche_tags if ! @catche_tags.nil? if resource = Catche::ResourceLoader.fetch_one(self, self.class.catche_resource_name) tags = Catche::Tag::Collect.resource(resource) @catche_tags = tags[:set] else tags = Catche::Tag::Collect.collection(self, self.class.catche_model) @catche_tags = tags[:set] end end def _save_fragment(name, options={}) if options[:catche] key = fragment_cache_key(name) Catche::Tag.tag! key, *catche_tags end super end end end end ActionController::Base.send :include, Catche::Controller::Base
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
catche-0.2.1 | lib/catche/controller/base.rb |
catche-0.2 | lib/catche/controller/base.rb |