Class: Symbol
- Inherits:
-
Object
- Object
- Symbol
- Defined in:
- lib/json/add/symbol.rb
Overview
Symbol serialization/deserialization
Class Method Summary collapse
-
.json_create(o) ⇒ Object
Deserializes JSON string by converting the
string
value stored in the object to a Symbol.
Instance Method Summary collapse
-
#as_json ⇒ Object
Returns a hash, that will be turned into a JSON object and represent this object.
-
#to_json(*a) ⇒ Object
Stores class name (Symbol) with String representation of Symbol as a JSON string.
Class Method Details
.json_create(o) ⇒ Object
Deserializes JSON string by converting the string
value stored in the object to a Symbol
23 24 25 |
# File 'lib/json/add/symbol.rb', line 23 def self.json_create(o) o['s'].to_sym end |
Instance Method Details
#as_json ⇒ Object
Returns a hash, that will be turned into a JSON object and represent this object.
10 11 12 13 14 15 |
# File 'lib/json/add/symbol.rb', line 10 def as_json(*) { JSON.create_id => self.class.name, 's' => to_s, } end |
#to_json(*a) ⇒ Object
Stores class name (Symbol) with String representation of Symbol as a JSON string.
18 19 20 |
# File 'lib/json/add/symbol.rb', line 18 def to_json(*a) as_json.to_json(*a) end |