Module: Ably::Modules::ModelCommon::ClassMethods

Defined in:
lib/ably/modules/model_common.rb

Instance Method Summary collapse

Instance Method Details

#from_json(json_like_object) ⇒ Object

Return a new instance of this object using the provided JSON-like object or JSON string

Parameters:

  • json_like_object (Hash, String)

    JSON-like object or JSON string

Returns:

  • a new instance to this object



67
68
69
70
71
72
73
# File 'lib/ably/modules/model_common.rb', line 67

def from_json(json_like_object)
  if json_like_object.kind_of?(String)
    new(JSON.parse(json_like_object))
  else
    new(json_like_object)
  end
end