Module: Crummy::ViewMethods

Defined in:
lib/crummy/action_view.rb

Instance Method Summary collapse

Instance Method Details

#add_crumb(name, url = nil, options = {}) ⇒ Object

Add a crumb to the crumbs array



9
10
11
# File 'lib/crummy/action_view.rb', line 9

def add_crumb(name, url=nil, options={})
  crumbs.push [name, url, options]
end

#crumbsObject

List the crumbs as an array



4
5
6
# File 'lib/crummy/action_view.rb', line 4

def crumbs
  @_crumbs ||= [] # Give me something to push to
end

#render_crumbs(options = {}) ⇒ Object

Render the list of crumbs using renderer

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/crummy/action_view.rb', line 15

def render_crumbs(options = {})
  raise ArgumentError, "Renderer and block given" if options.has_key?(:renderer) && block_given?
  return yield(crumbs, options) if block_given?
  
  @_renderer ||= if options.has_key?(:renderer)
    options.delete(:renderer)
  else
    require 'crummy/standard_renderer'
    Crummy::StandardRenderer.new
  end

  @_renderer.render_crumbs(crumbs, options)
end