Module: EasyTable::ViewExt::Row::Data

Defined in:
lib/easy-table/row/data.rb

Instance Method Summary collapse

Instance Method Details

#attribute_cells(object, attributes, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/easy-table/row/data.rb', line 23

def attribute_cells object, attributes, options = {}
  options.delete(:row_classes)
  content = []
  reset_cycle('cells')      
  attributes.each do |attrib|
    cls_opt = class_option(:cell_classes, options, :name => 'cells')
    
    content << cell(object, attrib, options.merge(cls_opt))
    content << ''.indent(2) if attrib == attributes.last
  end
  content.join.html_safe
end

#data_row(object, attributes, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/easy-table/row/data.rb', line 13

def data_row object, attributes, options={}            
  row_content = attribute_cells object, attributes, options.clone

  cls_opt = class_option(:row_classes, options, :name => 'rows')
  options[:row] ||= {}
  options[:row].merge!(cls_opt)
  
  indent_tag(2, :tr, row_content, options[:row]).html_safe
end

#data_rows(collection, attributes, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/easy-table/row/data.rb', line 3

def data_rows collection, attributes, options = {}
  content = []
  reset_cycle('rows')
  collection.each do |obj|                        
    row_content = data_row(obj, attributes, options)        
    content << indent(2) + row_content
  end      
  content.join.html_safe
end