Class: Compendium::Presenters::Settings::Table
- Defined in:
- app/classes/compendium/presenters/settings/table.rb
Instance Attribute Summary collapse
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
Instance Method Summary collapse
- #format(column, &block) ⇒ Object
- #formatters ⇒ Object
-
#initialize(headings) ⇒ Table
constructor
A new instance of Table.
- #override_heading(*args, &block) ⇒ Object
Methods inherited from Query
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
#headings ⇒ Object (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 |
#formatters ⇒ Object
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 |