Class: TableSortable::Columns

Inherits:
Array
  • Object
show all
Defined in:
lib/table_sortable/columns.rb

Instance Method Summary collapse

Constructor Details

#initializeColumns

Returns a new instance of Columns.



4
5
6
# File 'lib/table_sortable/columns.rb', line 4

def initialize
  super
end

Instance Method Details

#add(col_name, *options) ⇒ Object



8
9
10
11
# File 'lib/table_sortable/columns.rb', line 8

def add(col_name, *options)
  options = options.extract_options!
  self << TableSortable::Column.new(col_name, options)
end

#sort_by(sort_key) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/table_sortable/columns.rb', line 13

def sort_by(sort_key)
  if sort_key
    sort_key.map{|c| self.find{|col| (c.is_a?(String) ? (col.label == c) : col.name == c)}}
  else
    self
  end
end