Module: Proscenium::UI::Breadcrumbs::Control::ClassMethods

Defined in:
lib/proscenium/ui/breadcrumbs/control.rb

Instance Method Summary collapse

Instance Method Details

#add_breadcrumb(name, path = nil, **options) ⇒ Object

Appends a new breadcrumb element into the collection.

Parameters:

  • name (String, Symbol, Proc, #for_breadcrumb)

    The name or content of the breadcrumb.

  • path (String, Symbol, Array, Proc, nil) (defaults to: nil)

    The path (route) to use as the HREF for the breadcrumb.

  • options (Hash)

    Filter options to pass through to the before_action filter. Options include :if, :unless, :only, and :except. Any options not included in the filter options will be passed as options to the breadcrumb element. For example, you could pass a :class option to add a CSS class to the breadcrumb element.



25
26
27
28
29
30
31
32
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 25

def add_breadcrumb(name, path = nil, **options)
  filter_options = options.slice(:if, :unless, :only, :except)
  element_options = options.except(:if, :unless, :only, :except)

  before_action(filter_options) do |controller|
    controller.send :add_breadcrumb, name, path, element_options
  end
end

#prepend_breadcrumb(name, path = nil, **options) ⇒ Object

Prepend a new breadcrumb element into the collection.

Parameters:

  • name (String, Symbol, Proc, #for_breadcrumb)

    The name or content of the breadcrumb.

  • path (String, Symbol, Array, Proc, nil) (defaults to: nil)

    The path (route) to use as the HREF for the breadcrumb.

  • options (Hash)

    Filter options to pass through to the before_action filter. Options include :if, :unless, :only, and :except. Any options not included in the filter options will be passed as options to the breadcrumb element. For example, you could pass a :class option to add a CSS class to the breadcrumb element.



43
44
45
46
47
48
49
50
# File 'lib/proscenium/ui/breadcrumbs/control.rb', line 43

def prepend_breadcrumb(name, path = nil, **options)
  filter_options = options.slice(:if, :unless, :only, :except)
  element_options = options.except(:if, :unless, :only, :except)

  before_action(filter_options) do |controller|
    controller.send :prepend_breadcrumb, name, path, element_options
  end
end