Module: OnStomp::Components::Scopes

Included in:
OnStomp::Client
Defined in:
lib/onstomp/components/scopes.rb

Overview

Mixin for clients to create frame scopes.

Defined Under Namespace

Classes: HeaderScope, ReceiptScope, TransactionScope

Instance Method Summary (collapse)

Instance Method Details

- (OnStomp::Components::Scopes::TransactionScope) transaction(tx_id = nil) {|t| ... }

Creates a new TransactionScope and evaluates the block within that scope if one is given.

Parameters:

  • tx_id (String) (defaults to: nil)

    optional id for the transaction

Yields:

  • (t)

    block of frames to generate within a transaction

Yield Parameters:

Returns:

See Also:



22
23
24
25
26
# File 'lib/onstomp/components/scopes.rb', line 22

def transaction tx_id=nil, &block
  OnStomp::Components::Scopes::TransactionScope.new(tx_id, self).tap do |t|
    t.perform(&block) if block
  end
end

- (OnStomp::Components::Scopes::HeaderScope) with_headers(headers) {|h| ... }

Creates a new HeaderScope that will apply the provided headers to all frames generated on the scope. If a block is given, it will be evaluated within this scope.

Parameters:

  • headers ({#to_sym => #to_s})

Yields:

  • (h)

    block of frames to apply headers to

Yield Parameters:

Returns:

See Also:

  • OnStomp::Components::Scopes::HeaderScope#perform


36
37
38
39
40
# File 'lib/onstomp/components/scopes.rb', line 36

def with_headers headers
  OnStomp::Components::Scopes::HeaderScope.new(headers, self).tap do |h|
    yield h if block_given?
  end
end

- (OnStomp::Components::Scopes::ReceiptScope) with_receipt {|r| ... }

Creates a new ReceiptScope. Any receipt-able frame generated on this scope will automatically have the supplied callback attached as a RECEIPT handler.

Yields:

  • (r)

    callback to be invoked when the RECEIPT frame is received

Yield Parameters:

Returns:



11
12
13
# File 'lib/onstomp/components/scopes.rb', line 11

def with_receipt &block
  OnStomp::Components::Scopes::ReceiptScope.new(block, self)
end