Sha256: de0635ae7d943fc19e7795a0b8d4f3dbfdcf4c096824ab4471d5741f088b4bda

Contents?: true

Size: 767 Bytes

Versions: 7

Compression:

Stored size: 767 Bytes

Contents

# -*- encoding: utf-8 -*-

# Adds a receipt callback to all receipt-able frames generated on this scope
class OnStomp::Components::Scopes::ReceiptScope
  include OnStomp::Interfaces::FrameMethods
  
  attr_reader :callback, :client, :connection
  
  def initialize callback, client
    @callback = callback
    @client = client
    @connectio = client.connection
  end
  
  # Wraps {OnStomp::Client#transmit}, applying the {#callback} as a receipt
  # handler for all frames before they are sent to the broker.
  # @param [OnStomp::Components::Frame] frame
  # @param [{Symbol => Proc}] cbs
  # @return [OnStomp::Components::Frame]
  # @see OnStomp::Client#transmit
  def transmit frame, cbs={}
    cbs[:receipt] ||= callback
    client.transmit frame, cbs
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onstomp-1.0.5 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.4 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.3 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.2 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.1 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.0 lib/onstomp/components/scopes/receipt_scope.rb
onstomp-1.0.0pre1 lib/onstomp/components/scopes/receipt_scope.rb