Class: Struct

Inherits:
Object show all
Defined in:
lib/json/add/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(object) ⇒ Object



106
107
108
# File 'lib/json/add/core.rb', line 106

def self.json_create(object)
  new(*object['v'])
end

Instance Method Details

#to_json(*args) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/json/add/core.rb', line 110

def to_json(*args)
  klass = self.class.name
  klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
  {
    JSON.create_id => klass,
    'v'     => values,
  }.to_json(*args)
end