Module: Cheveret::Table::Mapping
- Included in:
- Base
- Defined in:
- lib/cheveret/table/mapping.rb
Defined Under Namespace
Modules: Mappable
Class Method Summary collapse
Instance Method Summary collapse
- #table_data(column, item) ⇒ Object
- #table_data_for(column, item) ⇒ Object
- #table_header(column) ⇒ Object
- #table_header_for(column) ⇒ Object
Class Method Details
Instance Method Details
#table_data(column, item) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cheveret/table/mapping.rb', line 39 def table_data(column, item) args = [ item ] case column.data when Symbol args.unshift(column) if method(column.data).arity > 1 send(column.data, *args) when Proc args.unshift(column) if column.data.arity > 1 template.capture(*args, &column.data) else if respond_to?(column.name) args.unshift(column) if method(column.name).arity > 1 send(column.name, *args) else table_data_for(column, item) end end end |
#table_data_for(column, item) ⇒ Object
62 63 64 |
# File 'lib/cheveret/table/mapping.rb', line 62 def table_data_for(column, item) raise NotImplementedError end |
#table_header(column) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/cheveret/table/mapping.rb', line 69 def table_header(column) case column.header when Symbol then send(column.header) when Proc then template.capture(&column.header) when String then column.header else table_header_for(column) unless column.header == false end end |
#table_header_for(column) ⇒ Object
82 83 84 |
# File 'lib/cheveret/table/mapping.rb', line 82 def table_header_for(column) raise NotImplementedError end |