Sha256: 3e973b8dc2a41ebad1380896b3fe035daa226758f6ce29d15bc687b83c9d5337

Contents?: true

Size: 768 Bytes

Versions: 17

Compression:

Stored size: 768 Bytes

Contents

require "forwardable"
require "singleton"

module Hermes
  class Publisher
    include Singleton
    extend Forwardable

    attr_reader :configuration, :mutex
    private     :configuration, :mutex

    def_delegators :current_adapter, :publish

    def initialize(configuration: Hermes::DependenciesContainer["config"])
      super()
      @configuration = configuration
      @mutex = Mutex.new
    end

    def reset
      self.current_adapter = nil
    end

    def current_adapter=(adapter)
      mutex.synchronize do
        @current_adapter = adapter
      end
    end

    def current_adapter
      mutex.synchronize do
        @current_adapter ||= begin
          Hermes::PublisherFactory.build(configuration.adapter)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hermes-rb-0.10.1 lib/hermes/publisher.rb
hermes-rb-0.10.0 lib/hermes/publisher.rb
hermes-rb-0.9.1 lib/hermes/publisher.rb
hermes-rb-0.9.0 lib/hermes/publisher.rb
hermes-rb-0.8.0 lib/hermes/publisher.rb
hermes-rb-0.7.5 lib/hermes/publisher.rb
hermes-rb-0.7.4 lib/hermes/publisher.rb
hermes-rb-0.7.3 lib/hermes/publisher.rb
hermes-rb-0.7.2 lib/hermes/publisher.rb
hermes-rb-0.7.1 lib/hermes/publisher.rb
hermes-rb-0.7.0 lib/hermes/publisher.rb
hermes-rb-0.6.1 lib/hermes/publisher.rb
hermes-rb-0.6.0 lib/hermes/publisher.rb
hermes-rb-0.5.0 lib/hermes/publisher.rb
hermes-rb-0.4.0 lib/hermes/publisher.rb
hermes-rb-0.3.1 lib/hermes/publisher.rb
hermes-rb-0.3.0 lib/hermes/publisher.rb