Sha256: e95fced37b77eaf5e8a99bf1e2568652af1fb405aff545e49f01cc0bfe7b4778
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
module TableHelp module Formatter module_function def format_attribute_name(name, collection_or_resource) return if name.blank? if collection_or_resource.respond_to?(:model) collection_or_resource.model.human_attribute_name(name) else collection_or_resource.class.human_attribute_name(name) end end def format_value(name, value) case value when DateTime, Time I18n.l(value) when Numeric (name.to_sym == :id) ? value : value.to_s(:delimited) when TrueClass, FalseClass value.to_s when NilClass name ? tag.em(:empty) : nil else value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_help-0.1.0 | lib/table_help/formatter.rb |