Sha256: c2dff9342cbdc2860b667568b9ed743f6c5d1c3c32b0442b698764494d4b7fe0

Contents?: true

Size: 751 Bytes

Versions: 14

Compression:

Stored size: 751 Bytes

Contents

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

# Adds the a set of headers to all frames generated on the scope.
class OnStomp::Components::Scopes::HeaderScope
  include OnStomp::Interfaces::FrameMethods
  
  attr_reader :headers, :client, :connection
  
  def initialize headers, client
    @headers = headers
    @client = client
    @connection = client.connection
  end
  
  # Wraps {OnStomp::Client#transmit}, applying the set of {#headers} to
  # all frames befor they are delivered to the broker.
  # @param [OnStomp::Components::Frame] frame
  # @param [{Symbol => Proc}] cbs
  # @return [OnStomp::Components::Frame]
  # @see OnStomp::Client#transmit
  def transmit frame, cbs={}
    frame.headers.reverse_merge!(headers)
    client.transmit frame, cbs
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
onstomp-1.0.12 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.11 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.10 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.9 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.8 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.7 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.6 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.5 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.4 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.3 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.2 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.1 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.0 lib/onstomp/components/scopes/header_scope.rb
onstomp-1.0.0pre1 lib/onstomp/components/scopes/header_scope.rb