Class: DefaultValueFormatter

Inherits:
JSONAPI::ValueFormatter show all
Defined in:
lib/jsonapi/formatter.rb

Class Method Summary collapse

Methods inherited from JSONAPI::ValueFormatter

unformat, value_formatter_for

Methods inherited from JSONAPI::Formatter

cached, formatter_for, uncached, unformat

Class Method Details

.format(raw_value) ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/jsonapi/formatter.rb', line 123

def format(raw_value)
  case raw_value
    when Date, Time, DateTime, ActiveSupport::TimeWithZone, BigDecimal
      # Use the as_json methods added to various base classes by ActiveSupport
      return raw_value.as_json
    else
      return raw_value
  end
end