Class: OnStomp::Components::Scopes::HeaderScope
- Inherits:
-
Object
- Object
- OnStomp::Components::Scopes::HeaderScope
- Includes:
- Interfaces::FrameMethods
- Defined in:
- lib/onstomp/components/scopes/header_scope.rb
Overview
Adds the a set of headers to all frames generated on the scope.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(headers, client) ⇒ HeaderScope
constructor
A new instance of HeaderScope.
-
#transmit(frame, cbs = {}) ⇒ OnStomp::Components::Frame
Wraps OnStomp::Client#transmit, applying the set of #headers to all frames befor they are delivered to the broker.
Methods included from Interfaces::FrameMethods
#abort, #ack, #beat, #begin, #commit, #disconnect, #nack, #send, #subscribe, #unsubscribe
Constructor Details
#initialize(headers, client) ⇒ HeaderScope
Returns a new instance of HeaderScope.
9 10 11 12 13 |
# File 'lib/onstomp/components/scopes/header_scope.rb', line 9 def initialize headers, client @headers = headers @client = client @connection = client.connection end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/onstomp/components/scopes/header_scope.rb', line 7 def client @client end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/onstomp/components/scopes/header_scope.rb', line 7 def connection @connection end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/onstomp/components/scopes/header_scope.rb', line 7 def headers @headers end |
Instance Method Details
#transmit(frame, cbs = {}) ⇒ OnStomp::Components::Frame
Wraps OnStomp::Client#transmit, applying the set of #headers to all frames befor they are delivered to the broker.
21 22 23 24 |
# File 'lib/onstomp/components/scopes/header_scope.rb', line 21 def transmit frame, cbs={} frame.headers.reverse_merge!(headers) client.transmit frame, cbs end |