Sha256: e66392471a1ccfb397b797909ea83ebdbb2b35a0b0f47062bbe38e20e14de5c2

Contents?: true

Size: 435 Bytes

Versions: 8

Compression:

Stored size: 435 Bytes

Contents

# frozen_string_literal: true

# Dumping and loading serialized tokens in JSON format.
module DeviseJwtAuth::Concerns::TokensSerialization
  # Serialization hash to json
  def self.dump(object)
    object&.each_value(&:compact!)
    JSON.generate(object)
  end

  # Deserialization json to hash
  def self.load(json)
    case json
    when String
      JSON.parse(json)
    when NilClass
      {}
    else
      json
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
devise_jwt_auth722-0.1.7 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth7-0.1.7 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.4.1 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.4.0 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.3.0 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.2.0 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.1.7 app/models/devise_jwt_auth/concerns/tokens_serialization.rb
devise_jwt_auth-0.1.6 app/models/devise_jwt_auth/concerns/tokens_serialization.rb