Class: Isimud::TestClient::Queue
- Inherits:
-
Object
- Object
- Isimud::TestClient::Queue
- Defined in:
- lib/isimud/test_client.rb
Instance Attribute Summary (collapse)
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) routing_keys
readonly
Returns the value of attribute routing_keys.
Instance Method Summary (collapse)
- - (Object) bind(exchange, options = {})
- - (Boolean) has_matching_key?(route)
-
- (Queue) initialize(name, listener)
constructor
A new instance of Queue.
- - (Object) publish(data)
Constructor Details
- (Queue) initialize(name, listener)
Returns a new instance of Queue
9 10 11 12 13 |
# File 'lib/isimud/test_client.rb', line 9 def initialize(name, listener) @name = name @listener = listener @routing_keys = Set.new end |
Instance Attribute Details
- (Object) name (readonly)
Returns the value of attribute name
7 8 9 |
# File 'lib/isimud/test_client.rb', line 7 def name @name end |
- (Object) routing_keys (readonly)
Returns the value of attribute routing_keys
7 8 9 |
# File 'lib/isimud/test_client.rb', line 7 def routing_keys @routing_keys end |
Instance Method Details
- (Object) bind(exchange, options = {})
15 16 17 18 |
# File 'lib/isimud/test_client.rb', line 15 def bind(exchange, = {}) key = [:routing_key] @routing_keys << Regexp.new(key.gsub(/\./, "\\.").gsub(/\*/, ".*")) end |
- (Boolean) has_matching_key?(route)
20 21 22 |
# File 'lib/isimud/test_client.rb', line 20 def has_matching_key?(route) @routing_keys.any? { |k| route =~ k } end |
- (Object) publish(data)
24 25 26 27 28 29 30 31 |
# File 'lib/isimud/test_client.rb', line 24 def publish(data) begin @listener.call(data) rescue => e puts "TestClient: error delivering message: #{e.}\n #{e.backtrace.join("\n ")}" @listener.exception_handler.try(:call, e) end end |