Module: Stomper::Extensions::Scoping

Included in:
Connection
Defined in:
lib/stomper/extensions/scoping.rb

Overview

Provides the scoping interface for a Connection object.

Instance Method Summary collapse

Instance Method Details

#with_headers(headers) {|header_scope| ... } ⇒ Stomper::Scopes::HeaderScope

Creates a new Scopes::HeaderScope from the supplied hash of headers. If a block is provided, it will be invoked with with this Scopes::HeaderScope as its only parameter.

Examples:

Gonna need an example or two

Parameters:

  • headers ({Symbol => Object})

Yields:

  • (header_scope)

    block is evaluated applying the specified headers to all frames generated within the block.

Yield Parameters:

Returns:



46
47
48
# File 'lib/stomper/extensions/scoping.rb', line 46

def with_headers(headers, &block)
  create_scope(::Stomper::Scopes::HeaderScope, headers, block)
end

#with_receipt(headers = {}) {|receipt| ... } ⇒ Stomper::Scopes::ReceiptScope

Creates a new Scopes::ReceiptScope using a supplied block as the receipt handler. If no block is provided, no receipt handler is created; however, all frames generated through this Scopes::ReceiptScope will still request a RECEIPT from the broker.

Examples:

Gonna need an example or two

Parameters:

  • headers ({Symbol => Object}) (defaults to: {})

Yields:

  • (receipt)

    callback invoked upon receiving the RECEIPT frame

Yield Parameters:

Returns:

See Also:

  • Events#on_receipt}


33
34
35
# File 'lib/stomper/extensions/scoping.rb', line 33

def with_receipt(headers={}, &block)
  create_scope(::Stomper::Scopes::ReceiptScope, headers, block)
end

#with_transaction(headers = {}) {|tx| ... } ⇒ Stomper::Scopes::TransactionScope

Creates a new Scopes::TransactionScope to perform a transaction. If a block is provided, all SEND, ACK, NACK, COMMIT and ABORT frames generated within the block are bound to the same transaction. Further, if an exception is raised within the block, the transaction is rolled back through an ABORT frame, otherwise it is automatically committed through a COMMIT frame. If a block is not provided, the transaction must be manually aborted or committed through the returned Scopes::TransactionScope object.

Examples:

Gonna need an example or two

Parameters:

  • headers ({Symbol => Object}) (defaults to: {})

Yields:

  • (tx)

    block is evaluated as a transaction

Yield Parameters:

Returns:



18
19
20
# File 'lib/stomper/extensions/scoping.rb', line 18

def with_transaction(headers={}, &block)
  create_scope(::Stomper::Scopes::TransactionScope, headers, block)
end