Module: Cheveret::Table::Columns::ClassMethods

Defined in:
lib/cheveret/table/columns.rb

Instance Method Summary collapse

Instance Method Details

#column(*args) ⇒ Object

define a new (or re-define an existing) table column

Raises:

  • (ArgumentError)


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cheveret/table/columns.rb', line 46

def column(*args)
  options = args.extract_options!
  raise ArgumentError if args.empty?

  column_name = args.first

  # only create new column if one doesn't already exist with specified name
  columns[column_name] ||= Column.new(column_name)
  columns[column_name].tap do |column|
    column.config(options)
  end
end

#columnsObject

returns an ordered hash of all defined table columns



39
40
41
# File 'lib/cheveret/table/columns.rb', line 39

def columns
  @columns ||= ::ActiveSupport::OrderedHash.new
end

#remove_column(column_name) ⇒ Object



62
63
64
# File 'lib/cheveret/table/columns.rb', line 62

def remove_column(column_name)
  columns.delete(column_name)
end