Module: ActiveWindow::ActiveTreeStoreColumns::ClassMethods

Defined in:
lib/active_window/active_tree_store/columns.rb

Instance Method Summary collapse

Instance Method Details

#column(label, type, opts = {}) ⇒ Object

options:

:virtual:  (bool )does not take actual values
:visible:  (bool) should be shown in the view


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/active_window/active_tree_store/columns.rb', line 33

def column(label,type, opts={})
  return columns[column_id[label.to_sym]] if column_id.has_key?(label.to_sym) # do not double-define
  opts.reverse_merge!(:visible => true, :virtual => false)
  index = column_count
  column_id[label.to_sym] = index
  col = ActiveColumn.create(index, label, type, opts)
  columns << col
  const_set label.to_s.upcase, index
  class_eval <<-EOCODE
    def self.#{label}_column
      #{index}
    end
  EOCODE
  return col
end

#column_classesObject



77
78
79
# File 'lib/active_window/active_tree_store/columns.rb', line 77

def column_classes
  columns.map(&:data_class)
end

#column_countObject



73
74
75
# File 'lib/active_window/active_tree_store/columns.rb', line 73

def column_count
  columns.size
end

#composite_column(label) {|col| ... } ⇒ Object

Yields:

  • (col)


49
50
51
52
53
54
# File 'lib/active_window/active_tree_store/columns.rb', line 49

def composite_column(label)
  col = ActiveCompositeColumn.new(label)
  yield col
  columns << col
  return col
end

#data_columnsObject

visible vs. virtual



61
62
63
# File 'lib/active_window/active_tree_store/columns.rb', line 61

def data_columns
  columns.reject(&:virtual?)
end

#invisible_columnsObject



69
70
71
# File 'lib/active_window/active_tree_store/columns.rb', line 69

def invisible_columns
  columns.reject(&:visible?)
end

#setup_column_id_constantsObject



81
82
83
84
85
# File 'lib/active_window/active_tree_store/columns.rb', line 81

def setup_column_id_constants
  column_id.each do |sym, index|
    const_set sym.to_s.upcase, index
  end
end

#virtual_column(label, type, opts = {}) ⇒ Object



56
57
58
# File 'lib/active_window/active_tree_store/columns.rb', line 56

def virtual_column(label, type, opts={})
  column label, type, opts.merge(:virtual => true)
end

#visible_columnsObject



65
66
67
# File 'lib/active_window/active_tree_store/columns.rb', line 65

def visible_columns
  columns.select(&:visible?)
end