Class: Struct

Inherits:
Object show all
Defined in:
lib/gems/json_pure-1.1.3/lib/json/add/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(object) ⇒ Object



93
94
95
# File 'lib/gems/json_pure-1.1.3/lib/json/add/core.rb', line 93

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

Instance Method Details

#to_json(*args) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/gems/json_pure-1.1.3/lib/json/add/core.rb', line 97

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