Method: Bootstrap4Helper::Accordion#initialize

Defined in:
lib/bootstrap4_helper/accordion.rb

#initialize(template, opts = {}, &block) ⇒ Accordion

Class constructor

Parameters:

  • template (ActionView)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id (String)
  • :class (String)
  • :data (Hash)
  • :parent (String)
  • :target (String)
  • :expanded (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bootstrap4_helper/accordion.rb', line 24

def initialize(template, opts = {}, &block)
  super(template)

  @id       = opts.fetch(:id,       uuid)
  @class    = opts.fetch(:class,    '')
  @data     = opts.fetch(:data,     {})
  @parent   = opts.fetch(:parent,   nil)
  @expanded = opts.fetch(:expanded, false)
  @target   = @data.fetch(:target,  uuid)
  @content  = block || proc { '' }
  @card     = Card.new(@template)
end