Sha256: e7e4fec6b6d52517c13bf1e57536841283b2858d8a50f8075af6881f54cd5c01

Contents?: true

Size: 538 Bytes

Versions: 11

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module StoreModel
  module Types
    # 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.
    class RawJSONEncoder < String
      def encode_json(_encoder)
        self
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
store_model-4.2.0 lib/store_model/types/raw_json.rb
store_model-4.1.0 lib/store_model/types/raw_json.rb
store_model-4.0.0 lib/store_model/types/raw_json.rb
store_model-3.0.2 lib/store_model/types/raw_json.rb
store_model-3.0.1 lib/store_model/types/raw_json.rb
store_model-3.0.0 lib/store_model/types/raw_json.rb
store_model-2.4.0 lib/store_model/types/raw_json.rb
store_model-2.3.0 lib/store_model/types/raw_json.rb
store_model-2.2.0 lib/store_model/types/raw_json.rb
store_model-2.1.2 lib/store_model/types/raw_json.rb
store_model-2.1.1 lib/store_model/types/raw_json.rb