Sha256: 87340af701cacbe6e3cb1164e3d7f49dc2526b1b3c3a0d2f23f38e11d855f0ab
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module TableHelp class Config DEFAULT_OPTIONS = { table_for: { class: "table table-striped table-hover table_for", }, attributes_table_for: { class: "table table-striped table-hover attributes_table_for", }, }.freeze DEFAULT_FORMATTER = { attribute_name: ->(name, collection_or_resource) do case collection_or_resource when ActiveRecord::Relation collection_or_resource.model.human_attribute_name(name) when Enumerable collection_or_resource.first.class.human_attribute_name(name) unless collection_or_resource.empty? else collection_or_resource.class.human_attribute_name(name) end end, value: ->(name, value) do case value when DateTime, Time I18n.l(value) when Numeric name.to_s.match?(/\Aid\z|_id\z/) ? value : value.to_s(:delimited) when TrueClass, FalseClass value.to_s else value end end, }.freeze attr_accessor :default_options, :formatter def initialize @default_options = DEFAULT_OPTIONS @formatter = DEFAULT_FORMATTER end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
table_help-0.2.0 | lib/table_help/config.rb |
table_help-0.1.7 | lib/table_help/config.rb |