Module: OnStomp::OpenURI::ClientExtensions
- Defined in:
- lib/onstomp/open-uri/client_extensions.rb
Overview
Mixin of extensions added to clients when they are created by opening a stomp:// URI.
Instance Attribute Summary (collapse)
-
- (Object) auto_destination
Returns the value of attribute auto_destination.
-
- (Object) openuri_message_queue
readonly
Returns the value of attribute openuri_message_queue.
Class Method Summary (collapse)
-
+ (Object) extended(inst)
Aliases #send_with_openuri as
send
.
Instance Method Summary (collapse)
-
- (Enumerator, self) each {|m| ... }
Creates a subscription to #auto_destination and yields each MESSAGE frame read from the subscription to the supplied block.
-
- (OnStomp::Components::Frame+) first(n = nil)
(also: #take, #gets)
Returns
n
frames read from the subscription. -
- (OnStomp::Components::Frame) send_with_openuri(*args, &block)
Adds the ability for clients to generate SEND frames without specifying a destination by using #auto_destination instead.
Instance Attribute Details
- (Object) auto_destination
Returns the value of attribute auto_destination
6 7 8 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 6 def auto_destination @auto_destination end |
- (Object) openuri_message_queue (readonly)
Returns the value of attribute openuri_message_queue
6 7 8 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 6 def @openuri_message_queue end |
Class Method Details
+ (Object) extended(inst)
Aliases #send_with_openuri as send
9 10 11 12 13 14 15 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 9 def self.extended inst inst.instance_eval do alias :send_without_openuri :send alias :send :send_with_openuri alias :puts :send end end |
Instance Method Details
- (Enumerator, self) each {|m| ... }
Creates a subscription to #auto_destination and yields each MESSAGE frame read from the subscription to the supplied block. If no block is provided an enumerator is returned.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 35 def each(&block) if block subscribe_to_auto_destination loop do yield .shift end else OnStomp::ENUMERATOR_KLASS.new(self) end end |
- (OnStomp::Components::Frame+) first(n = nil) Also known as: take, gets
Returns n
frames read from the subscription. If n
is ommited,
the next frame is returned, otherwise an array of the next n
frames
is returned.
52 53 54 55 56 57 58 59 60 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 52 def first(n=nil) to_recv = n || 1 received = [] each do |m| received << m break if received.size == to_recv end n ? received : received.first end |
- (OnStomp::Components::Frame) send_with_openuri(*args, &block)
Adds the ability for clients to generate SEND frames without specifying a destination by using #auto_destination instead.
20 21 22 23 24 25 26 27 |
# File 'lib/onstomp/open-uri/client_extensions.rb', line 20 def send_with_openuri *args, &block headers = args.last.is_a?(Hash) ? args.pop : {} dest, body = args if body.nil? body, dest = dest, verified_auto_destination end send_without_openuri dest, body, headers, &block end |