Sha256: b252bd6a08b797d35403aa0a744aeb484c8ac91f57ae3c347e492067c2c15e33

Contents?: true

Size: 535 Bytes

Versions: 5

Compression:

Stored size: 535 Bytes

Contents

module Vault
  module Rails
    module JSONSerializer
      DECODE_OPTIONS = {
        max_nested:       false,
        create_additions: false,
      }.freeze

      def self.encode(raw)
        _init!

        JSON.fast_generate(raw)
      end

      def self.decode(raw)
        _init!

        return nil if raw == nil || raw == ""

        JSON.parse(raw, DECODE_OPTIONS)
      end

      protected

      def self._init!
        return if defined?(@_init)
        require "json"
        @_init = true
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vault-rails-0.8.0 lib/vault/rails/json_serializer.rb
vault-rails-0.7.1 lib/vault/rails/json_serializer.rb
vault-rails-0.7.0 lib/vault/rails/json_serializer.rb
vault-rails-0.6.0 lib/vault/rails/json_serializer.rb
vault-rails-0.5.0 lib/vault/rails/json_serializer.rb