Class: Syncano::Packets::Call
Overview
Class representing call packets used in communication with the Sync Server
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
Attributes inherited from Base
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Hash
Overwritten method for preparing hash for json serialization.
-
#initialize(attributes) ⇒ Call
constructor
Constructor for Syncano::Packets::Call object.
Methods inherited from Base
#auth?, #call_response?, instantize_packet, #message?, #notification?, #ping?
Constructor Details
#initialize(attributes) ⇒ Call
Constructor for Syncano::Packets::Call object
9 10 11 12 13 14 15 |
# File 'lib/syncano/packets/call.rb', line 9 def initialize(attributes) super(attributes) self.resource_name = attributes[:resource_name] self.method_name = attributes[:method_name] self.data = attributes[:data] self. = attributes[:message_id] || rand(10**12) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/syncano/packets/call.rb', line 5 def data @data end |
#message_id ⇒ Object
Returns the value of attribute message_id.
5 6 7 |
# File 'lib/syncano/packets/call.rb', line 5 def @message_id end |
#method_name ⇒ Object
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/syncano/packets/call.rb', line 5 def method_name @method_name end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
5 6 7 |
# File 'lib/syncano/packets/call.rb', line 5 def resource_name @resource_name end |
Instance Method Details
#as_json(options = {}) ⇒ Hash
Overwritten method for preparing hash for json serialization
20 21 22 23 24 25 26 27 |
# File 'lib/syncano/packets/call.rb', line 20 def as_json( = {}) { type: 'call', method: "#{resource_name}.#{method_name}", params: data, message_id: .to_s } end |