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)
- 
  
    
      - (Object) callback 
    
    
  
  
  
    readonly
    
  
  
  
  
  
  
    
Returns the value of attribute callback.
 - 
  
    
      - (Object) frame 
    
    
  
  
  
    readonly
    
  
  
  
  
  
  
    
Returns the value of attribute frame.
 
Instance Method Summary (collapse)
- 
  
    
      - (Object) call(m) 
    
    
  
  
  
  
  
  
  
  
    
Invokes the #callback, passing along the supplied MESSAGE frame.
 - 
  
    
      - (String) destination 
    
    
  
  
  
  
  
  
  
  
    
Returns the
destinationheader of the associated SUBSCRIBE frame. - 
  
    
      - (String) id 
    
    
  
  
  
  
  
  
  
  
    
Returns the
idheader of the associated SUBSCRIBE frame. - 
  
    
      - (true, false) include?(m) 
    
    
  
  
  
  
  
  
  
  
    
Returns true if this message frame shares the same destination as this subscription, false otherwise.
 - 
  
    
      - (Subscription) initialize(fr, cb) 
    
    
  
  
    constructor
  
  
  
  
  
  
  
    
Creates a new subscription.
 
Constructor Details
- (Subscription) initialize(fr, cb)
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
- (Object) callback (readonly)
Returns the value of attribute callback
      7 8 9  | 
    
      # File 'lib/onstomp/components/subscription.rb', line 7 def callback @callback end  | 
  
- (Object) frame (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
- (Object) call(m)
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  | 
  
- (String) destination
Returns the destination header of the associated SUBSCRIBE frame
      20  | 
    
      # File 'lib/onstomp/components/subscription.rb', line 20 def destination; frame[:destination]; end  | 
  
- (String) id
Returns the id header of the associated SUBSCRIBE frame
      17  | 
    
      # File 'lib/onstomp/components/subscription.rb', line 17 def id; frame[:id]; end  | 
  
- (true, false) include?(m)
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  |