Class: TableHelper::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/flexa_lib/table_for_boolean_column.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#boolean_column(*args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flexa_lib/table_for_boolean_column.rb', line 10

def boolean_column(*args, &block)
  col_options = args.extract_options!
  res = nil

  col_options[:html] = { :th => { :width => "1%",:style=>"text-align: center;" }, 
              :td => { :style=>"text-align: center;" }}

  attr = args.shift or nil

  if block_given?
    col_options[:callback] = block
    @columns << (res = CallbackColumn.new(@template, @records, attr, col_options))
  elsif attr
    @columns << (res = BooleanColumn.new(@template, @records, attr, col_options))
  else
    raise ArgumentError, "Attribute name or block should be given"
  end
  res
end