class Aerogel::Admin::TableBuilder::Column

Constants

KNOWN_OPTIONS

Attributes

block[RW]
field[RW]
label[RW]
options[RW]
table[RW]

Public Class Methods

new( table, field, options = {}, &block ) click to toggle source
# File lib/aerogel/admin/table_builder.rb, line 62
def initialize( table, field, options = {}, &block )
  self.table = table
  self.field = field
  self.options = options
  self.block = block
  self.label = self.options[:label] || self.field.to_sym
end

Public Instance Methods

html_params() click to toggle source

Renders html params for column cells

# File lib/aerogel/admin/table_builder.rb, line 88
def html_params
  attrs = @options.except( *KNOWN_OPTIONS )
  attrs = attrs.deep_merge( @options[:html_params] ) if @options.key? :html_params
  attrs.to_html_params
end
human_label() click to toggle source
# File lib/aerogel/admin/table_builder.rb, line 70
def human_label
  if label.is_a? Symbol
    if table.object.respond_to? :human_attribute_name
      table.object.human_attribute_name label, default: label
    elsif table.object.respond_to?( :first ) &&  table.object.first.class.respond_to?( :human_attribute_name )
      table.object.first.class.human_attribute_name label, default: label
    else
      I18n.t label
    end
  elsif label.is_a? String
    label
  else
    label.to_s.humanize
  end
end