Class: PanelHelper::PanelCreator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, FormatHelper
Defined in:
app/helpers/panel_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Constructor Details

#initialize(content = nil, options, block) ⇒ PanelCreator

Returns a new instance of PanelCreator.



13
14
15
16
17
# File 'app/helpers/panel_helper.rb', line 13

def initialize(content=nil, options, block)
  @content = content
  @options = options
  @block   = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



10
11
12
# File 'app/helpers/panel_helper.rb', line 10

def block
  @block
end

#contentObject

Returns the value of attribute content.



8
9
10
# File 'app/helpers/panel_helper.rb', line 8

def content
  @content
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'app/helpers/panel_helper.rb', line 9

def options
  @options
end

#output_bufferObject

Returns the value of attribute output_buffer.



11
12
13
# File 'app/helpers/panel_helper.rb', line 11

def output_buffer
  @output_buffer
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/panel_helper.rb', line 19

def render
  heading = options.delete(:heading)
  title   = options.delete(:title)
  footer  = options.delete(:footer)
  tag     = options.delete(:tag).try(:to_sym).presence || :div
  type    = get_panel_type(options.delete(:type))

  prepend_class(options, 'panel', type)

   tag, options do
    (panel_header(heading, title) + panel_body(content, block) +
      panel_footer(footer)).html_safe
  end
end