Class: Compendium::Presenters::Settings::Table

Inherits:
Query
  • Object
show all
Defined in:
app/classes/compendium/presenters/settings/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#method_missing

Constructor Details

#initialize(headings) ⇒ Table

Returns a new instance of Table.



5
6
7
8
# File 'app/classes/compendium/presenters/settings/table.rb', line 5

def initialize(headings)
  super()
  @headings = Hash[headings.zip(headings)].with_indifferent_access
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Compendium::Presenters::Settings::Query

Instance Attribute Details

#headingsObject (readonly)

Returns the value of attribute headings.



3
4
5
# File 'app/classes/compendium/presenters/settings/table.rb', line 3

def headings
  @headings
end

Instance Method Details

#format(column, &block) ⇒ Object



22
23
24
25
# File 'app/classes/compendium/presenters/settings/table.rb', line 22

def format(column, &block)
  @settings[:formatters] ||= {}
  @settings[:formatters][column] = block
end

#formattersObject



27
28
29
# File 'app/classes/compendium/presenters/settings/table.rb', line 27

def formatters
  (@settings[:formatters] || {})
end

#override_heading(*args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/classes/compendium/presenters/settings/table.rb', line 10

def override_heading(*args, &block)
  if block_given?
    @headings.each do |key, val|
      res = yield val
      @headings[key] = res if res
    end
  else
    col, label = args
    @headings[col] = label
  end
end