Module: DeviseTokenAuth::Concerns::TokensSerialization
- Defined in:
- app/models/devise_token_auth/concerns/tokens_serialization.rb
Class Method Summary collapse
-
.dump(object) ⇒ Object
Serialization hash to json.
-
.load(json) ⇒ Object
Deserialization json to hash.
Class Method Details
.dump(object) ⇒ Object
Serialization hash to json
3 4 5 6 |
# File 'app/models/devise_token_auth/concerns/tokens_serialization.rb', line 3 def self.dump(object) object.each_value(&:compact!) unless object.nil? JSON.generate(object) end |
.load(json) ⇒ Object
Deserialization json to hash
9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/devise_token_auth/concerns/tokens_serialization.rb', line 9 def self.load(json) case json when String JSON.parse(json) when NilClass {} else json end end |