Module: TrailerVote::Api::JsonTypeAdapter
- Defined in:
- lib/trailer_vote/api/fallback_content_types.rb
Class Method Summary collapse
Class Method Details
.decode(obj) ⇒ Object
17 18 19 20 21 |
# File 'lib/trailer_vote/api/fallback_content_types.rb', line 17 def decode(obj) Oj.load(obj, mode: :strict, symbol_keys: true) rescue Oj::Error => err raise DecodeError.new(media_type: 'application/json', source: err) end |
.encode(obj) ⇒ Object
11 12 13 14 15 |
# File 'lib/trailer_vote/api/fallback_content_types.rb', line 11 def encode(obj) Oj.dump(obj, mode: :compat) rescue Oj::Error => err raise EncodeError.new(media_type: 'application/json', source: err) end |