module Data::Formatting
Public Instance Methods
apply_formats(locals: {}, controller: nil)
click to toggle source
# File lib/tabulatr/data/formatting.rb, line 26 def apply_formats(locals: {}, controller: nil) view = Tabulatr::Data::Proxy.new(locals: locals, controller: controller) return @relation.map do |record| view.record = record h = HashWithIndifferentAccess.new table_columns.each do |tc| h[tc.table_name] ||= HashWithIndifferentAccess.new h[tc.table_name][tc.name] = tc.value_for(record, view) end h[:_row_config] = format_row(view, @row) h[:id] = record.id h end # @relation map end
format_row(view, row)
click to toggle source
# File lib/tabulatr/data/formatting.rb, line 41 def format_row(view, row) row_config = Row.new view.instance_exec(view.record, row_config.attributes, &row) if row.is_a?(Proc) view.record.define_singleton_method(:_row_config) do row_config.attributes end row_config.attributes end