Sha256: 6d2df2649d42e4c70b76314bbe25bb4d76508c5781471da4b58e1629143ba246

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

Stored size: 1.15 KB

Contents

# -*- encoding: utf-8 -*-
require 'open-uri'

class OnStomp::Components::URI::STOMP
  # Creates a new {OnStomp::Client}, extends it with
  # {OnStomp::OpenURI::ClientExtensions} and either returns it directly or
  # connects it, yields it to a given block and the disconnects it.
  # @param [arg1, arg2, ...] args additional arguments to pass to {OnStomp::Client#initialize}
  # @yield [client] block to evaluate within a connected client
  # @yieldparam [OnStomp::Client] client
  # @return [OnStomp::Client]
  def open(*args)
    client = OnStomp::Client.new(self, *args)
    client.extend OnStomp::OpenURI::ClientExtensions
    client.auto_destination = self.path
    if block_given?
      begin
        client.connect
        yield client
      ensure
        client.disconnect
      end
    end
    client
  end
end

# Namespace for OnStomp open-uri extensions.
module OnStomp::OpenURI
  # Raised if a client's
  # {OnStomp::OpenURI::ClientExtensions#auto_destination auto_destination} has
  # not been properly set.
  class UnusableDestinationError < OnStomp::OnStompError; end
end

require 'onstomp/open-uri/message_queue'
require 'onstomp/open-uri/client_extensions'

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
onstomp-1.0.12 lib/onstomp/open-uri.rb
onstomp-1.0.11 lib/onstomp/open-uri.rb
onstomp-1.0.10 lib/onstomp/open-uri.rb
onstomp-1.0.9 lib/onstomp/open-uri.rb
onstomp-1.0.8 lib/onstomp/open-uri.rb
onstomp-1.0.7 lib/onstomp/open-uri.rb
onstomp-1.0.6 lib/onstomp/open-uri.rb
onstomp-1.0.5 lib/onstomp/open-uri.rb
onstomp-1.0.4 lib/onstomp/open-uri.rb
onstomp-1.0.3 lib/onstomp/open-uri.rb
onstomp-1.0.2 lib/onstomp/open-uri.rb
onstomp-1.0.1 lib/onstomp/open-uri.rb
onstomp-1.0.0 lib/onstomp/open-uri.rb