Class: Snaptable::Helpers::Table

Inherits:
Constructor::BaseTable show all
Defined in:
lib/snaptable/helpers/table.rb

Defined Under Namespace

Modules: Search

Instance Method Summary collapse

Methods inherited from Constructor::BaseTable

#column_names, #options, #url

Methods included from Constructor::Renderer

#present, #respond

Methods included from Constructor::Collection

#collection, #filter, #records

Methods included from Constructor::Sortable

#css_class, #direction, #page, #sort_column, #sort_direction, #sortable

Constructor Details

#initialize(parent, model, collection = nil, options = {}) ⇒ Table

Returns a new instance of Table.



8
9
10
11
# File 'lib/snaptable/helpers/table.rb', line 8

def initialize(parent, model, collection = nil, options = {})
  super(parent, collection, options)
  @model = model
end

Instance Method Details

#modelObject



23
24
25
# File 'lib/snaptable/helpers/table.rb', line 23

def model
  @model
end

#values(element) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/snaptable/helpers/table.rb', line 13

def values(element)
  element.attributes.map do |attr_name, attr_value|
    if attr_value.is_a?(Date) || attr_value.is_a?(Time) || attr_value.is_a?(DateTime)
      l(attr_value, format: :short)
    else
      attr_value
    end.to_s
  end
end