Module: Ably::Modules::ModelCommon

Overview

Common model functionality shared across many Ably::Models

Instance Method Summary collapse

Methods included from MessagePack

#to_msgpack

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
# File 'lib/ably/modules/model_common.rb', line 18

def ==(other)
  other.kind_of?(self.class) &&
    hash == other.hash
end

#[](key) ⇒ Object

Provide a normal Hash accessor to the underlying raw message object

Returns:

  • (Object)


14
15
16
# File 'lib/ably/modules/model_common.rb', line 14

def [](key)
  hash[key]
end

#as_jsonObject

Return a JSON ready object from the underlying #hash using Ably naming conventions for keys



24
25
26
# File 'lib/ably/modules/model_common.rb', line 24

def as_json
  hash.as_json.reject { |key, val| val.nil? }
end

#to_json(*args) ⇒ Object

Stringify the JSON representation of this object from the underlying #hash



29
30
31
# File 'lib/ably/modules/model_common.rb', line 29

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