Class: OnStomp::Components::Subscription

Inherits:
Object
  • Object
show all
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)

Instance Method Summary (collapse)

Constructor Details

- (Subscription) initialize(fr, cb)

Creates a new subscription

Parameters:



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

Parameters:

  • m (OnStomp::Componenets::Frame)

    the associated 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

Returns:

  • (String)


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

Returns:

  • (String)


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.

Returns:

  • (true, false)


27
28
29
# File 'lib/onstomp/components/subscription.rb', line 27

def include? m
  self.destination == m[:destination]
end