Class: ActiveScaffold::DataStructures::ActionColumns

Inherits:
Set
  • Object
show all
Includes:
Configurable
Defined in:
lib/active_scaffold/data_structures/action_columns.rb

Overview

A set of columns. These structures can be nested for organization.

Defined Under Namespace

Modules: AfterConfiguration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

#configure, #method_missing

Methods inherited from Set

#add, #each, #empty?, #exclude, #find_by_name, #find_by_names, #initialize, #length

Constructor Details

This class inherits a constructor from ActiveScaffold::DataStructures::Set

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable

Instance Attribute Details

#actionObject

this lets us refer back to the action responsible for this link, if it exists. the immediate need here is to get the crud_type so we can dynamically filter columns from the set.



8
9
10
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 8

def action
  @action
end

#collapsedObject

Whether this column set is collapsed by default in contexts where collapsing is supported



19
20
21
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 19

def collapsed
  @collapsed
end

#labelObject Also known as: name



12
13
14
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 12

def label
  as_(@label) if @label
end

Instance Method Details

#add_subgroup(label, insert_index = nil, &proc) ⇒ Object

nests a subgroup in the column set



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 22

def add_subgroup(label, insert_index = nil, &proc)
  columns = ActiveScaffold::DataStructures::ActionColumns.new
  columns.label = label
  columns.action = self.action
  columns.configure &proc
  self.exclude columns.collect_columns
  if insert_index.nil?
    self.add columns
  else
    self.add columns, insert_index
  end

end

#include?(item) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 36

def include?(item)
  @set.any? do |c|
    case c
    when Symbol
      c == item.to_sym
    when ActiveScaffold::DataStructures::Column
      c.name == item.to_sym
    when ActiveScaffold::DataStructures::ActionColumns
      !c.is_a? Symbol and c.include? item
    end
  end
end

#namesObject



49
50
51
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 49

def names
  self.collect(&:name)
end

#names_without_auth_checkObject



53
54
55
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 53

def names_without_auth_check
  Array(@set)
end

#select(&block) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/active_scaffold/data_structures/action_columns.rb', line 57

def select(&block)
  self.convert_to_columns unless columns_converted?
  #columns = ActiveScaffold::DataStructures::ActionColumns.new
  columns = self.clone
  #ActiveScaffold::DataStructures::ActionColumns.class_eval {include ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration}
  #columns.label = self.label
  #columns.action = self.action
  columns.instance_variable_get('@set').clear
  cols = @set.select &block

  columns.add cols
  columns
end