Class: Ext::Grid::ActiveRecord

Inherits:
EditableColumnModel
  • Object
show all
Includes:
Column
Defined in:
lib/ext/grid/active_record.rb

Instance Method Summary collapse

Instance Method Details

#grid_column(column) ⇒ Object



26
27
28
# File 'lib/ext/grid/active_record.rb', line 26

def grid_column(column)
  grid_column_class(column).new(column.name, column.name.to_s.humanize)
end

#grid_column_class(column) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ext/grid/active_record.rb', line 12

def grid_column_class(column)
  return PrimaryKeyColumn if column.primary

  case column.type
  when :integer  then IntegerColumn
  when :string   then StringColumn
  when :text     then TextColumn
  when :datetime then DatetimeColumn
  when :date     then DateColumn
  else
    StringColumn
  end
end

#optionsObject



4
5
6
7
8
9
10
# File 'lib/ext/grid/active_record.rb', line 4

def options
  disabled = @options.delete(:disabled) || []
  disabled = [disabled] unless disabled.is_a?(Array)
  klass.columns.map do |c|
    grid_column(c).to_config(disabled)
  end
end