Class: TableHelp::Config
- Inherits:
-
Object
- Object
- TableHelp::Config
- Defined in:
- lib/table_help/config.rb
Constant Summary collapse
- 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
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
39 40 41 42 |
# File 'lib/table_help/config.rb', line 39 def initialize @default_options = DEFAULT_OPTIONS @formatter = DEFAULT_FORMATTER end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
37 38 39 |
# File 'lib/table_help/config.rb', line 37 def @default_options end |
#formatter ⇒ Object
Returns the value of attribute formatter.
37 38 39 |
# File 'lib/table_help/config.rb', line 37 def formatter @formatter end |