Class: Hermes::Publisher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/hermes/publisher.rb

Defined Under Namespace

Classes: HutchAdapter, InMemoryAdapter

Instance Method Summary collapse

Constructor Details

#initialize(configuration: Hermes::DependenciesContainer["config"]) ⇒ Publisher

Returns a new instance of Publisher.



14
15
16
17
18
# File 'lib/hermes/publisher.rb', line 14

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

Instance Method Details

#current_adapterObject



30
31
32
33
34
35
36
# File 'lib/hermes/publisher.rb', line 30

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

#current_adapter=(adapter) ⇒ Object



24
25
26
27
28
# File 'lib/hermes/publisher.rb', line 24

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

#resetObject



20
21
22
# File 'lib/hermes/publisher.rb', line 20

def reset
  self.current_adapter = nil
end