Module: DeviseTokenAuth::Concerns::TokensSerialization

Extended by:
TokensSerialization
Included in:
TokensSerialization
Defined in:
app/models/devise_token_auth/concerns/tokens_serialization.rb

Instance Method Summary collapse

Instance Method Details

#dump(object) ⇒ Object

Serialization hash to json



4
5
6
7
8
# File 'app/models/devise_token_auth/concerns/tokens_serialization.rb', line 4

def dump(object)
  JSON.generate(object && object.transform_values do |token|
    serialize_updated_at(token).compact
  end.compact)
end

#load(json) ⇒ Object

Deserialization json to hash



11
12
13
14
15
16
17
18
19
20
# File 'app/models/devise_token_auth/concerns/tokens_serialization.rb', line 11

def load(json)
  case json
  when String
    JSON.parse(json)
  when NilClass
    {}
  else
    json
  end
end