Class: StoreModel::Types::RawJSONEncoder

Inherits:
String
  • Object
show all
Defined in:
lib/store_model/types/raw_json.rb

Overview

Implements #encode_json and #as_json methods. By wrapping serialized objects in this type, it prevents duplicate JSON serialization passes on nested object. It is named as Encoder as it will not work to inflate typed attributes and is intended to be used internally.

Instance Method Summary collapse

Instance Method Details

#as_json(_options = nil) ⇒ Object



15
16
17
# File 'lib/store_model/types/raw_json.rb', line 15

def as_json(_options = nil)
  JSON.parse(self)
end

#encode_json(_encoder) ⇒ Object



11
12
13
# File 'lib/store_model/types/raw_json.rb', line 11

def encode_json(_encoder)
  self
end