Class: Bootstrap3Helper::AccordionGroup
- Defined in:
- lib/bootstrap3_helper/accordion_group.rb
Overview
This class is used to general groups of accordions.
Instance Method Summary collapse
-
#accordion(context_or_options = nil, opts = {}) {|accordion| ... } ⇒ Object
This method is the main method for generating individual accordions.
-
#initialize(template, opts = {}, &block) ⇒ AccordionGroup
constructor
Used to initialize the main object.
-
#to_s ⇒ String
The to string method here is what is responsible for rendering out the entire accordion.
Methods inherited from Component
#concat, #content_tag, #parse_arguments, #uuid
Constructor Details
#initialize(template, opts = {}, &block) ⇒ AccordionGroup
Used to initialize the main object. This objects sole purpose is to generate a wrapper element with a distinct id and pass that id down to all the child elements.
39 40 41 42 43 44 45 46 |
# File 'lib/bootstrap3_helper/accordion_group.rb', line 39 def initialize(template, opts = {}, &block) super(template) @id = opts.fetch(:id, uuid) @class = opts.fetch(:class, '') @data = opts.fetch(:data, {}) @content = block || proc { '' } end |
Instance Method Details
#accordion(context_or_options = nil, opts = {}) {|accordion| ... } ⇒ Object
This method is the main method for generating individual accordions. This is where you would pass in the html attributes.
57 58 59 60 61 62 63 64 65 |
# File 'lib/bootstrap3_helper/accordion_group.rb', line 57 def accordion( = nil, opts = {}, &block) if .is_a?(Hash) [:parent_id] = @id else opts[:parent_id] = @id end Accordion.new(@template, , opts, &block) end |
#to_s ⇒ String
The to string method here is what is responsible for rendering out the entire accordion. As long as the main method is rendered out in the helper, you will get all the contents.
73 74 75 76 77 |
# File 'lib/bootstrap3_helper/accordion_group.rb', line 73 def to_s content = content_tag :div, id: @id, class: "panel-group #{@class}" do @content.call(self) end end |