Class: Navigasmic::Builder::ListBuilder
- Defined in:
- lib/navigasmic/builders/list_builder.rb
Defined Under Namespace
Classes: Configuration
Instance Method Summary collapse
- #group(label_or_options = nil, options = {}, &block) ⇒ Object
-
#initialize(context, name, options, &block) ⇒ ListBuilder
constructor
A new instance of ListBuilder.
- #item(label, *args, &block) ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(context, name, options, &block) ⇒ ListBuilder
Returns a new instance of ListBuilder.
34 35 36 37 38 |
# File 'lib/navigasmic/builders/list_builder.rb', line 34 def initialize(context, name, , &block) super @options[:id] ||= name.to_s.underscore unless @options.has_key?(:id) @options[:class] = merge_classes!(@options, @config.wrapper_class) 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_or_options = nil, options = {}, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/navigasmic/builders/list_builder.rb', line 44 def group( = nil, = {}, &block) raise ArgumentError, "Missing block for group" unless block_given? if .is_a?(Hash) = = nil end return '' unless visible?() concat(structure_for(, false, , &block)) end |
#item(label, *args, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/navigasmic/builders/list_builder.rb', line 55 def item(label, *args, &block) = args. = () return '' unless visible?() item = Navigasmic::Item.new(label, extract_and_determine_link(label, , *args), visible?(), ) merge_classes!(, @config.item_class) merge_classes!(, @config.disabled_class) if item.disabled? merge_classes!(, @config.highlighted_class) if item.highlights_on?(@context.request.path, @context.params) concat(structure_for(label, item.link? ? item.link : false, , &block)) end |
#render ⇒ Object
40 41 42 |
# File 'lib/navigasmic/builders/list_builder.rb', line 40 def render content_tag(@config.wrapper_tag, capture(&@definition), @options) end |