Module: Ration
- Defined in:
- lib/ration.rb,
lib/ration/hub.rb,
lib/ration/sse.rb,
lib/ration/rails.rb,
lib/ration/errors.rb,
lib/ration/version.rb,
lib/ration/subscription.rb,
lib/ration/backends/base.rb,
lib/ration/configuration.rb,
lib/ration/backends/redis.rb,
lib/ration/backends/memory.rb,
lib/ration/backends/postgres.rb
Defined Under Namespace
Modules: Backends, Rails, SSE
Classes: Configuration, Error, Hub, NotConfigured, PayloadTooLarge, Subscription
Constant Summary
collapse
- VERSION =
'0.2.2'
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
21
22
23
|
# File 'lib/ration.rb', line 21
def config
@config ||= Configuration.new
end
|
11
12
13
14
15
16
17
18
19
|
# File 'lib/ration.rb', line 11
def configure
yield config
backend = config.backend or
raise NotConfigured, 'No backend configured. Set config.backend to a Ration::Backends::* instance.'
@hub&.stop
@hub = Hub.new(backend: backend, logger: config.logger)
end
|
.publish(event) ⇒ Object
25
26
27
|
# File 'lib/ration.rb', line 25
def publish(event)
hub.publish(event)
end
|
.reset! ⇒ Object
37
38
39
40
41
|
# File 'lib/ration.rb', line 37
def reset!
@hub&.stop
@hub = nil
@config = nil
end
|
.subscribe ⇒ Object
29
30
31
|
# File 'lib/ration.rb', line 29
def subscribe(...)
hub.subscribe(...) end
|
.unsubscribe(sub) ⇒ Object
33
34
35
|
# File 'lib/ration.rb', line 33
def unsubscribe(sub)
hub.unsubscribe(sub)
end
|