module Erector::Caching

Public Class Methods

included(base) click to toggle source
# File lib/erector/caching.rb, line 38
def self.included(base)
  base.extend ClassMethods
end

Public Instance Methods

cache() click to toggle source
# File lib/erector/caching.rb, line 68
def cache
  self.class.cache
end
should_cache?() click to toggle source
# File lib/erector/caching.rb, line 72
def should_cache?
  cache && block.nil? && self.class.cachable?
end

Protected Instance Methods

_emit(options = {}) click to toggle source
# File lib/erector/caching.rb, line 77
def _emit(options = {})
  if should_cache?
    cache[self.class, assigns, options[:content_method_name]] ||= super
  else
    super
  end
end
_emit_via(parent, options = {}) click to toggle source
# File lib/erector/caching.rb, line 85
def _emit_via(parent, options = {})
  if should_cache?
    parent.output << cache[self.class, assigns, options[:content_method_name]] ||= parent.capture { super }
    parent.output.widgets << self.class # todo: test!!!
  else
    super
  end
end