Class: PigeonHole::JSONSymbol

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pigeon_hole/json_symbol.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(o) ⇒ Object

Deserializes JSON string by converting the string value stored in the object to a Symbol



18
19
20
# File 'lib/pigeon_hole/json_symbol.rb', line 18

def self.json_create(o)
  o['s'].to_sym
end

Instance Method Details

#as_jsonObject

Returns a hash, that will be turned into a JSON object and represent this object.



5
6
7
8
9
10
# File 'lib/pigeon_hole/json_symbol.rb', line 5

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.



13
14
15
# File 'lib/pigeon_hole/json_symbol.rb', line 13

def to_json(*a)
  as_json.to_json(*a)
end