Module: Wisper

Defined in:
lib/wisper/registration/block.rb,
lib/wisper.rb,
lib/wisper/version.rb,
lib/wisper/publisher.rb,
lib/wisper/configuration.rb,
lib/wisper/global_listeners.rb,
lib/wisper/registration/object.rb,
lib/wisper/temporary_listeners.rb,
lib/wisper/value_objects/events.rb,
lib/wisper/value_objects/prefix.rb,
lib/wisper/registration/registration.rb,
lib/wisper/broadcasters/send_broadcaster.rb,
lib/wisper/broadcasters/logger_broadcaster.rb

Overview

Provides a way of wrapping another broadcaster with logging

Defined Under Namespace

Modules: Broadcasters, Publisher, ValueObjects Classes: BlockRegistration, Configuration, GlobalListeners, ObjectRegistration, Registration, TemporaryListeners

Constant Summary collapse

VERSION =
"4.0.0"

Class Method Summary collapse

Class Method Details

.clearObject



46
47
48
# File 'lib/wisper.rb', line 46

def self.clear
  GlobalListeners.clear
end

.configurationObject



54
55
56
# File 'lib/wisper.rb', line 54

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



50
51
52
# File 'lib/wisper.rb', line 50

def self.configure
  yield(configuration)
end

.publisherObject



42
43
44
# File 'lib/wisper.rb', line 42

def self.publisher
  Publisher
end

.setupObject



58
59
60
61
62
# File 'lib/wisper.rb', line 58

def self.setup
  configure do |config|
    config.broadcaster(:default, Broadcasters::SendBroadcaster.new)
  end
end

.subscribe(*args, **kwargs, &block) ⇒ Object

Examples:

Wisper.subscribe(AuditRecorder.new)

Wisper.subscribe(AuditRecorder.new, StatsRecorder.new)

Wisper.subscribe(AuditRecorder.new, on: 'order_created')

Wisper.subscribe(AuditRecorder.new, scope: 'MyPublisher')

Wisper.subscribe(AuditRecorder.new, StatsRecorder.new) do
  # ..
end


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

def self.subscribe(*args, **kwargs, &block)
  if block_given?
    TemporaryListeners.subscribe(*args, **kwargs, &block)
  else
    GlobalListeners.subscribe(*args, **kwargs)
  end
end

.unsubscribe(*listeners) ⇒ Object



38
39
40
# File 'lib/wisper.rb', line 38

def self.unsubscribe(*listeners)
  GlobalListeners.unsubscribe(*listeners)
end