Class: Navigasmic::Builder::CrumbBuilder
- Defined in:
- lib/navigasmic/builders/crumb_builder.rb
Defined Under Namespace
Classes: Configuration
Instance Method Summary collapse
- #group(label = nil, options = {}, &block) ⇒ Object
-
#initialize(context, name, options, &block) ⇒ CrumbBuilder
constructor
A new instance of CrumbBuilder.
- #item(label, *args, &block) ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(context, name, options, &block) ⇒ CrumbBuilder
Returns a new instance of CrumbBuilder.
23 24 25 26 27 |
# File 'lib/navigasmic/builders/crumb_builder.rb', line 23 def initialize(context, name, , &block) super @path = [] @crumb_path = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Navigasmic::Builder::Base
Instance Method Details
#group(label = nil, options = {}, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/navigasmic/builders/crumb_builder.rb', line 34 def group(label = nil, = {}, &block) if block_given? @crumb_path << label_for(label, false, false, ) if label capture(&block) end end |
#item(label, *args, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/navigasmic/builders/crumb_builder.rb', line 41 def item(label, *args, &block) = args. = () return '' unless visible?() merge_classes!(, @config.item_class) item = Navigasmic::Item.new(label, extract_and_determine_link(label, , *args), visible?(), ) if item.highlights_on?(@context.request.path, @context.params) @crumb_path << label_for(label, false, false, ) @path += @crumb_path @crumb_path = [] end if block_given? @crumb_path << label_for(label, item.link? ? item.link : false, false, ) if label capture(&block) end end |
#render ⇒ Object
29 30 31 32 |
# File 'lib/navigasmic/builders/crumb_builder.rb', line 29 def render capture(&@definition) @path.join(' ').html_safe end |