module BreadcrumbTrail::ActionController::HelperMethods

This is both included in the controller and used as a helper, so any methods defined here are usable in both the controller and in the views. These methods are the primary interface that the developer uses to define and render breadcrumbs.

Public Instance Methods

breadcrumb(options, &block) click to toggle source

Define a breadcrumb with the given options. All of this information is passed directly to the Breadcrumb initializer.

@see Breadcrumb#initialize @params options [Hash] A hash of options to pass directly to

the Breadcrumb.

@yield @return [void]

breadcrumbs() click to toggle source

All of the defined breadcrumbs, in order.

@return [Array<Breadcrumb>]

render_breadcrumbs(options = {}, &block) click to toggle source

Renders the defined breadcrumbs, with the given options.

@param options [Hash] The options that are passed to the

builder to help render the breadcrumbs.

@option options [Hash] :builder (Builder) The builder to use.

If this isn't provided, a sensible default is used.

@yield @return [String]

# File lib/breadcrumb_trail/action_controller.rb, line 64
def render_breadcrumbs(options = {}, &block)
  block_given = block_given?
  builder = options.fetch(:builder) do
    if block_given
      BlockBuilder
    else
      HTMLBuilder
    end
  end

  builder.new(self, breadcrumbs, options, &block).call
end