Class: NebulousStomp::StompHandlerNull

Inherits:
StompHandler show all
Defined in:
lib/nebulous_stomp/stomp_handler_null.rb

Overview

Behaves just like StompHandler, except, does nothing and expects no stomp connection

Instance Attribute Summary collapse

Attributes inherited from StompHandler

#client

Instance Method Summary collapse

Methods inherited from StompHandler

body_to_hash, #nebulous_on?, with_timeout

Constructor Details

#initialize(hash = {}) ⇒ StompHandlerNull

Returns a new instance of StompHandlerNull.



21
22
23
24
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 21

def initialize(hash={})
  super(hash)
  @fake_mess = nil
end

Instance Attribute Details

#fake_messObject (readonly)

Returns the value of attribute fake_mess.



18
19
20
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 18

def fake_mess
  @fake_mess
end

Instance Method Details

#calc_reply_idObject



89
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 89

def calc_reply_id; 'ABCD123456789'; end

#connected?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 47

def connected? 
  @fake_mess != nil
end

#insert_fake(message) ⇒ Object



27
28
29
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 27

def insert_fake(message)
  @fake_mess = message
end

#listen(queue) {|@fake_mess| ... } ⇒ Object

Yields:



52
53
54
55
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 52

def listen(queue)
  NebulousStomp.logger.info(__FILE__) {"Subscribing to #{queue} (on Null)"}
  yield @fake_mess
end

#listen_with_timeout(queue, timeout) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 58

def listen_with_timeout(queue, timeout)
  NebulousStomp.logger.info(__FILE__) {"Subscribing to #{queue} (on Null)"}

  if @fake_mess
    yield @fake_mess
  else
    sleep timeout
    raise NebulousStomp::NebulousTimeout
  end
end

#respond_error(nebMess, err, fields = []) ⇒ Object



82
83
84
85
86
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 82

def respond_error(nebMess,err,fields=[])
  NebulousStomp.logger.info(__FILE__) do
    "Responded to #{nebMess} with 'error' verb: #{err} (to Null)"
  end
end

#respond_success(nebMess) ⇒ Object



75
76
77
78
79
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 75

def respond_success(nebMess)
  NebulousStomp.logger.info(__FILE__) do 
    "Responded to #{nebMess} with 'success' verb (to Null)"
  end
end

#send_message(queue, nebMess) ⇒ Object



70
71
72
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 70

def send_message(queue, nebMess)
  nebMess
end

#stomp_connectObject



32
33
34
35
36
37
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 32

def stomp_connect
  NebulousStomp.logger.info(__FILE__) {"Connecting to STOMP (Null)"} 

  @client = true
  self
end

#stomp_disconnectObject



40
41
42
43
44
# File 'lib/nebulous_stomp/stomp_handler_null.rb', line 40

def stomp_disconnect
  NebulousStomp.logger.info(__FILE__) {"STOMP Disconnect (Null)"}
  @client = nil
  self
end