Sha256: 1aab202933a11aee61fa09553b22221b97c4395e6fa58baacd9eca8c5b4d3962

Contents?: true

Size: 380 Bytes

Versions: 2

Compression:

Stored size: 380 Bytes

Contents

module Toy
  module Types
    module JSON
      def self.to_store(value, *)
        return value if value.nil?
        ActiveSupport::JSON.encode(value)
      end

      def self.from_store(value, *)
        return value if value.nil?

        if value.is_a?(String)
          ActiveSupport::JSON.decode(value)
        else
          value
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toystore-0.13.2 lib/toy/types/json.rb
toystore-0.13.1 lib/toy/types/json.rb