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
-
#with_headers(headers) {|header_scope| ... } ⇒ Stomper::Scopes::HeaderScope
Creates a new Scopes::HeaderScope from the supplied hash of headers.
-
#with_receipt(headers = {}) {|receipt| ... } ⇒ Stomper::Scopes::ReceiptScope
Creates a new Scopes::ReceiptScope using a supplied block as the receipt handler.
-
#with_transaction(headers = {}) {|tx| ... } ⇒ Stomper::Scopes::TransactionScope
Creates a new Scopes::TransactionScope to perform a transaction.
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.
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.
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.
18 19 20 |
# File 'lib/stomper/extensions/scoping.rb', line 18 def with_transaction(headers={}, &block) create_scope(::Stomper::Scopes::TransactionScope, headers, block) end |