Class: OnStomp::Components::Subscription
- Inherits:
-
Object
- Object
- OnStomp::Components::Subscription
- Defined in:
- lib/onstomp/components/subscription.rb
Overview
A simple encapsulation of a subscription. Instances of this class keep track of the SUBSCRIBE frame they were generated for and the callback to invoke when a MESSAGE frame is received for the subscription.
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
Instance Method Summary collapse
-
#call(m) ⇒ Object
Invokes the #callback, passing along the supplied MESSAGE frame.
-
#destination ⇒ String
Returns the
destination
header of the associated SUBSCRIBE frame. -
#id ⇒ String
Returns the
id
header of the associated SUBSCRIBE frame. -
#include?(m) ⇒ true, false
Returns true if this message frame shares the same destination as this subscription, false otherwise.
-
#initialize(fr, cb) ⇒ Subscription
constructor
Creates a new subscription.
Constructor Details
#initialize(fr, cb) ⇒ Subscription
Creates a new subscription
11 12 13 14 |
# File 'lib/onstomp/components/subscription.rb', line 11 def initialize(fr, cb) @frame = fr @callback = cb end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
7 8 9 |
# File 'lib/onstomp/components/subscription.rb', line 7 def callback @callback end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
7 8 9 |
# File 'lib/onstomp/components/subscription.rb', line 7 def frame @frame end |
Instance Method Details
#call(m) ⇒ Object
Invokes the #callback, passing along the supplied MESSAGE frame
23 |
# File 'lib/onstomp/components/subscription.rb', line 23 def call(m); callback.call(m); end |
#destination ⇒ String
Returns the destination
header of the associated SUBSCRIBE frame
20 |
# File 'lib/onstomp/components/subscription.rb', line 20 def destination; frame[:destination]; end |
#id ⇒ String
Returns the id
header of the associated SUBSCRIBE frame
17 |
# File 'lib/onstomp/components/subscription.rb', line 17 def id; frame[:id]; end |
#include?(m) ⇒ true, false
Returns true if this message frame shares the same destination as this subscription, false otherwise.
27 28 29 |
# File 'lib/onstomp/components/subscription.rb', line 27 def include? m self.destination == m[:destination] end |