Class: HasGlobalSession::Encoding::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/has_global_session/encoding.rb

Overview

JSON serializer, used to serialize Hash objects in a form suitable for stuffing into a cookie.

Class Method Summary collapse

Class Method Details

.dump(object) ⇒ Object

Serialize Hash to JSON document.

Parameters

value(Hash)

The hash to be serialized

Return

json(String)

A JSON-serialized representation of value



27
28
29
# File 'lib/has_global_session/encoding.rb', line 27

def self.dump(object)
  return object.to_json
end

.load(json) ⇒ Object

Unserialize JSON to Hash.

Parameters

json(String)

A well-formed JSON document

Return

value(Hash)

An unserialized Ruby Hash



16
17
18
# File 'lib/has_global_session/encoding.rb', line 16

def self.load(json)
  ::JSON.load(json)
end