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

Defined in:
lib/submodules/ably-ruby/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



62
63
64
65
66
67
68
# File 'lib/submodules/ably-ruby/lib/ably/modules/model_common.rb', line 62

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