Module: Brainshell::ValueFormatter
- Included in:
- Commands::Base
- Defined in:
- lib/brainshell/value_formatter.rb
Constant Summary collapse
- KNOWN_FORMAT_METHODS =
{ BigDecimal => :big_decimal, DateTime => :date_time, Braintree::CreditCard => :model_with_token, Braintree::Subscription => :model_with_id }.freeze
Instance Method Summary collapse
Instance Method Details
#format_value(value) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/brainshell/value_formatter.rb', line 11 def format_value(value) if value.is_a? Array value.map { |item| format_value(item) }.join(',') else format_method = KNOWN_FORMAT_METHODS[value.class] format_method ? send(format_method, value) : value end end |