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.1'
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
22
23
24
|
# File 'lib/ration.rb', line 22
def config
@config ||= Configuration.new
end
|
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ration.rb', line 11
def configure
yield config
if config.backend.nil?
raise NotConfigured, 'No backend configured. Set config.backend to a Ration::Backends::* instance.'
end
@hub&.stop
@hub = Hub.new(backend: config.backend, logger: config.logger)
end
|
.publish(event) ⇒ Object
26
27
28
|
# File 'lib/ration.rb', line 26
def publish(event)
hub.publish(event)
end
|
.reset! ⇒ Object
38
39
40
41
42
|
# File 'lib/ration.rb', line 38
def reset!
@hub&.stop
@hub = nil
@config = nil
end
|
.subscribe(**kwargs, &block) ⇒ Object
30
31
32
|
# File 'lib/ration.rb', line 30
def subscribe(**kwargs, &block)
hub.subscribe(**kwargs, &block)
end
|
.unsubscribe(sub) ⇒ Object
34
35
36
|
# File 'lib/ration.rb', line 34
def unsubscribe(sub)
hub.unsubscribe(sub)
end
|