Module: MailerFragmentCaching
- Includes:
- ActionController::Caching::Fragments
- Defined in:
- lib/mailer_fragment_caching.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cache_configured? ⇒ Boolean
- #cache_store ⇒ Object
-
#instrument_fragment_cache(name, key) ⇒ Object
:nodoc:.
- #perform_caching ⇒ Object
- #view_cache_dependencies ⇒ Object
Class Method Details
.included(base) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mailer_fragment_caching.rb', line 24 def self.included(base) base.class_eval do class_attribute :_view_cache_dependencies self._view_cache_dependencies = [] helper_method :view_cache_dependencies if respond_to?(:helper_method) end end |
.view_cache_dependency(&dependency) ⇒ Object
32 33 34 |
# File 'lib/mailer_fragment_caching.rb', line 32 def self.view_cache_dependency(&dependency) self._view_cache_dependencies += [dependency] end |
Instance Method Details
#cache_configured? ⇒ Boolean
16 17 18 |
# File 'lib/mailer_fragment_caching.rb', line 16 def cache_configured? perform_caching && cache_store end |
#cache_store ⇒ Object
12 13 14 |
# File 'lib/mailer_fragment_caching.rb', line 12 def cache_store ActionController::Base.cache_store end |
#instrument_fragment_cache(name, key) ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/mailer_fragment_caching.rb', line 40 def instrument_fragment_cache(name, key) # :nodoc: yield if block_given? end |
#perform_caching ⇒ Object
8 9 10 |
# File 'lib/mailer_fragment_caching.rb', line 8 def perform_caching ActionController::Base.perform_caching end |
#view_cache_dependencies ⇒ Object
36 37 38 |
# File 'lib/mailer_fragment_caching.rb', line 36 def view_cache_dependencies self.class._view_cache_dependencies.map { |dep| instance_exec(&dep) }.compact end |