Sha256: cd8e5a86a8d7801631cf135fcb42fad19f1074d6d717bb83088bcc56eb126ca5
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module Catche module ViewHelpers # Caches a fragment # See ActionView `cache` for more information # # <% catche @project do %> # <%= @project.title %> # <% end %> # # <% catche @projects, :model => Project do %> # <% @projects.each do |project| %> # <%= project.title %> # <% end %> # <% end %> def catche(model_or_resource, options={}, &block) tags = [] name = Catche::Tag.join 'fragment', model_or_resource.hash key = ActiveSupport::Cache.expand_cache_key name, :views object = options[:model] || model_or_resource if object.respond_to?(:catche_tag) if object.respond_to?(:new) tags = Catche::Tag::Collect.collection(controller, object)[:set] else tags = Catche::Tag::Collect.resource(object)[:set] end end Catche::Tag.tag_view! key, *tags if tags.any? cache name, options, &block end alias :catches_fragment :catche end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
catche-0.2.5 | lib/catche/view_helpers.rb |