Class: Smartware::PubSubClient::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/smartware/pub_sub_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reliable_id, key, args, callback) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
# File 'lib/smartware/pub_sub_client.rb', line 8

def initialize(reliable_id, key, args, callback)
  @reliable_id = reliable_id
  @key = key
  @args = args
  @callback = callback
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/smartware/pub_sub_client.rb', line 6

def args
  @args
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/smartware/pub_sub_client.rb', line 6

def key
  @key
end

Instance Method Details

#[](index) ⇒ Object



29
30
31
# File 'lib/smartware/pub_sub_client.rb', line 29

def [](index)
  @args[index]
end

#acknowlegeObject



23
24
25
26
27
# File 'lib/smartware/pub_sub_client.rb', line 23

def acknowlege
  raise "message is not reliable" if @reliable_id.nil?

  @callback.call @reliable_id
end

#idObject



19
20
21
# File 'lib/smartware/pub_sub_client.rb', line 19

def id
  @reliable_id
end

#reliable?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/smartware/pub_sub_client.rb', line 15

def reliable?
  !@reliable_id.nil?
end

#to_aObject



33
34
35
# File 'lib/smartware/pub_sub_client.rb', line 33

def to_a
  @args
end