Module: SuperTable::ActionView

Defined in:
lib/super_table/action_view.rb

Instance Method Summary collapse

Instance Method Details

#super_table(table, options = {}, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/super_table/action_view.rb', line 6

def super_table(table, options={}, &block)

  options[:hover] = options.fetch(:hover, true)
  is_hover = options.delete(:hover)
  table_responsive = options.delete(:responsive)
  table_size = options.delete(:size).to_s

  classes = ['table']
  classes << options[:class] if options[:class]
  classes.push("table-hover") if is_hover && table.collection.present?
  classes.push("table-sm") if table_size == 'sm'

  options[:class] = classes.join(" ")

  case table_responsive.to_s
  when 'sm', 'md', 'lg', 'xl'
    (:div, class: "table-responsive-#{table_responsive}") do
      render_table(table, options, &block)
    end
  else
    render_table(table, options, &block)
  end
end