Module: ConfigSL::Format
- Included in:
- Config
- Defined in:
- lib/configsl/format.rb
Overview
TODO:
Should we add an option to cast nil?
Format option values.
This will format the values of the defined options when they are set on the config object. It will also format the values when they are retrieved, if they don't match their defined type.
The default behavior is to cast the value as the defined type. If the value is nil, it will be returned as is.
Constant Summary collapse
- FORMATTERS =
{ Array => :to_a, FalseClass => :to_b, Hash => :to_h, Integer => :to_i, String => ->(v) { v.to_s.encode('utf-8') }, Symbol => :to_sym, TrueClass => :to_b }.freeze