class Fragmentary::FragmentsHelper::CacheBuilder

Attributes

fragment[R]

Public Class Methods

new(template, fragment = nil) click to toggle source
# File lib/fragmentary/fragments_helper.rb, line 22
def initialize(template, fragment = nil)
  @fragment = fragment
  @template = template
end

Public Instance Methods

cache_child(options, &block)
Alias for: cache_fragment
cache_fragment(options) { |builder| ... } click to toggle source
# File lib/fragmentary/fragments_helper.rb, line 27
def cache_fragment(options, &block)
  no_cache = options.delete(:no_cache)
  insert_widgets = options.delete(:insert_widgets)
  options.reverse_merge!(:user => Template.new(@template).current_user)
  # If the CacheBuilder was instantiated with an existing fragment, next_fragment is its child;
  # otherwise it is the root fragment specified by the options provided.
  next_fragment = @fragment.try(:child, options) || Fragmentary::Fragment.base_class.root(options)
  builder = CacheBuilder.new(@template, next_fragment)
  unless no_cache
    @template.cache next_fragment, :skip_digest => true do
      yield(builder)
    end
  else
    yield(builder)
  end
  @template.output_buffer = WidgetParser.new(@template).parse_buffer if (!@fragment || insert_widgets)
end
Also aliased as: cache_child

Private Instance Methods

method_missing(method, *args) click to toggle source
# File lib/fragmentary/fragments_helper.rb, line 49
def method_missing(method, *args)
  @fragment.send(method, *args)
end