Module: Emittance

Defined in:
lib/emittance.rb,
lib/emittance/event.rb,
lib/emittance/action.rb,
lib/emittance/broker.rb,
lib/emittance/errors.rb,
lib/emittance/emitter.rb,
lib/emittance/version.rb,
lib/emittance/watcher.rb,
lib/emittance/notifier.rb,
lib/emittance/brokerage.rb,
lib/emittance/dispatcher.rb,
lib/emittance/middleware.rb,
lib/emittance/event_lookup.rb,
lib/emittance/topic_lookup.rb,
lib/emittance/middleware/logging.rb,
lib/emittance/brokers/synchronous.rb,
lib/emittance/helpers/string_helpers.rb,
lib/emittance/dispatchers/synchronous.rb,
lib/emittance/helpers/constant_helpers.rb,
lib/emittance/dispatcher/registration_map.rb,
lib/emittance/dispatcher/topic_registration_map.rb,
lib/emittance/dispatcher/registration_collection_proxy.rb

Overview

The base namespace for this library. You can do some basic configuration stuff by calling methods on its singleton.

Defined Under Namespace

Modules: Action, Brokerage, Emitter, EventLookup, Helpers, Notifier, TopicLookup, Watcher Classes: Broker, Dispatcher, Event, IdentifierCollisionError, IdentifierGenerationError, InvalidIdentifierError, InvalidPayloadError, Middleware, Synchronous

Constant Summary collapse

VERSION =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.event_routing_strategyObject

Returns the value of attribute event_routing_strategy


25
26
27
# File 'lib/emittance.rb', line 25

def event_routing_strategy
  @event_routing_strategy
end

Class Method Details

.clear_middleware!Object

Removes all middlewares from the app.


78
79
80
# File 'lib/emittance.rb', line 78

def clear_middleware!
  Emittance::Middleware.clear_registrations!
end

.default_brokerClass Also known as: broker

Returns the currently enabled broker class.

Returns:

  • (Class)

    the currently enabled broker class


43
44
45
# File 'lib/emittance.rb', line 43

def default_broker
  Emittance::Brokerage.default_broker
end

.default_broker=(identifier) ⇒ Object


65
66
67
# File 'lib/emittance.rb', line 65

def default_broker=(identifier)
  Emittance::Brokerage.default_broker = identifier
end

.default_dispatcherClass

Returns the dispatcher attached to the currently enabled broker.

Returns:

  • (Class)

    the dispatcher attached to the currently enabled broker


56
57
58
# File 'lib/emittance.rb', line 56

def default_dispatcher
  default_broker.dispatcher
end

.disable!Object

Disable eventing process-wide


33
34
35
# File 'lib/emittance.rb', line 33

def disable!
  Emittance::Brokerage.disable!
end

.dispatcher_for(*args) ⇒ Object Also known as: dispatcher


49
50
51
# File 'lib/emittance.rb', line 49

def dispatcher_for(*args)
  Emittance::Brokerage.dispatcher_for(*args)
end

.enable!Object

Enable eventing process-wide


28
29
30
# File 'lib/emittance.rb', line 28

def enable!
  Emittance::Brokerage.enable!
end

.enabled?Boolean

Returns true if eventing is enabled, false otherwise.

Returns:

  • (Boolean)

    true if eventing is enabled, false otherwise


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

def enabled?
  Emittance::Brokerage.enabled?
end

.use_broker(identifier) ⇒ Object

Parameters:

  • identifier (#to_sym)

    the identifier that can be used to identify the broker you wish to use


61
62
63
# File 'lib/emittance.rb', line 61

def use_broker(identifier)
  Emittance::Brokerage.use_broker identifier
end

.use_middleware(*middlewares) ⇒ Object

Emittance.use_middleware MyMiddleware

Emittance.use_middleware MyOtherMiddleware, MyCoolMiddleware

Parameters:

  • middlewares (Array<Class>)

    each middleware you wish to run.


73
74
75
# File 'lib/emittance.rb', line 73

def use_middleware(*middlewares)
  Emittance::Middleware.register middlewares
end