Class: BreadcrumbsOnRails::Breadcrumbs::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/breadcrumbs_on_rails/breadcrumbs.rb

Overview

The Builder class represents the abstract class for any custom Builder.

To create a custom Builder, just extend this class and implement the following abstract methods:

  • #render: Renders and returns the collection of navigation elements

Direct Known Subclasses

SimpleBuilder

Instance Method Summary collapse

Constructor Details

#initialize(context, elements, options = {}) ⇒ Builder

Initializes a new Builder with context, element and options.

Parameters:

  • context (ActionView::Base)

    The view context.

  • elements (Array<Element>)

    The collection of Elements.

  • options (Hash) (defaults to: {})

    Hash of options to customize the rendering behavior.


29
30
31
32
33
# File 'lib/breadcrumbs_on_rails/breadcrumbs.rb', line 29

def initialize(context, elements, options = {})
  @context  = context
  @elements = elements
  @options  = options
end

Instance Method Details

#renderString

This method is abstract.

You must implement this method in your custom Builder.

Renders Elements and returns the Breadcrumb navigation for the view.

Returns:

  • (String)

    The result of the breadcrumb rendering.

Raises:

  • (NotImplementedError)

40
41
42
# File 'lib/breadcrumbs_on_rails/breadcrumbs.rb', line 40

def render
  raise NotImplementedError
end