123456789_123456789_123456789_123456789_123456789_

Exception: Exception

Relationships & Source Files
Defined in: ext/json/lib/json/add/exception.rb

Class Method Summary

Instance Method Summary

  • #as_json

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

  • #to_json(*args)

    Stores class name (Exception) with message m and backtrace array b as ::JSON string.

Class Method Details

.json_create(object)

Deserializes JSON string by constructing new Exception object with message m and backtrace b serialized with #to_json

[ GitHub ]

  
# File 'ext/json/lib/json/add/exception.rb', line 9

def self.json_create(object)
  result = new(object['m'])
  result.set_backtrace object['b']
  result
end

Instance Method Details

#as_json

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

[ GitHub ]

  
# File 'ext/json/lib/json/add/exception.rb', line 17

def as_json(*)
  {
    JSON.create_id => self.class.name,
    'm'            => message,
    'b'            => backtrace,
  }
end

#to_json(*args)

Stores class name (Exception) with message m and backtrace array b as ::JSON string

[ GitHub ]

  
# File 'ext/json/lib/json/add/exception.rb', line 27

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