Module: Crumby::Helper::ControllerHelper

Extended by:
ActiveSupport::Concern
Defined in:
lib/crumby/helper/controller.rb

Overview

controller helper

Instance Method Summary collapse

Instance Method Details

#crumby(options) ⇒ Object #crumby(scope, options) ⇒ Object

render trail

Overloads:

  • #crumby(options) ⇒ Object

    Parameters:

    • options (Hash)

      passthrough to Trail#render

    Options Hash (options):

    • :scope (String, Symbol)

      extract scope from options before passthrough

  • #crumby(scope, options) ⇒ Object

    Parameters:

    • scope (Symbol, String)

      scope of trail

    • options (Hash)

      passthrough to Trail#render

    Options Hash (options):

    • :scope (String, Symbol)

      extract scope from options before passthrough

See Also:



31
32
33
34
35
# File 'lib/crumby/helper/controller.rb', line 31

def add_crumby(*args)
  options = args.extract_options!
  scope = options.delete(:scope) || :default
  crumby_trail(scope).add(*args, options)
end

#crumby(options) ⇒ Object #crumby(suffix, options) ⇒ Object

render trail

Overloads:

  • #crumby(options) ⇒ Object

    Parameters:

    • options (Hash)

      passthrough to Crumby::Trail#title

    Options Hash (options):

    • :scope (String, Symbol)

      extract scope from options before passthrough

  • #crumby(suffix, options) ⇒ Object

    Parameters:

    • suffix (String)

      passthrough to Crumby::Trail#title

    • options (Hash)

      passthrough to Crumby::Trail#title

    Options Hash (options):

    • :scope (String, Symbol)

      extract scope from options before passthrough

See Also:



47
48
49
50
51
# File 'lib/crumby/helper/controller.rb', line 47

def crumby_title(*args)
  options = args.extract_options!
  scope = options.delete(:scope) || :default
  crumby_trail(scope).title(*args, options)
end

#crumby_trail(scope = :default) ⇒ Object

return crumby_trail by scope

Parameters:

  • scope (Symbol, String) (defaults to: :default)

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/crumby/helper/controller.rb', line 14

def crumby_trail(scope = :default)
  raise ArgumentError if scope.nil?
  scope = scope.to_sym
  @crumby_trails = {} if @crumby_trails.nil?
  @crumby_trails[scope] ||= Crumby::Trail.new
end