Class: Announce::Adapters::BaseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/announce/adapters/base_adapter.rb

Direct Known Subclasses

InlineAdapter, ShoryukenAdapter, TestAdapter

Defined Under Namespace

Classes: BrokerManager, Destination, Queue, Subscriber, Topic

Class Method Summary collapse

Class Method Details

.adapter_constantize(name) ⇒ Object



29
30
31
# File 'lib/announce/adapters/base_adapter.rb', line 29

def adapter_constantize(name)
  "::Announce::Adapters::#{Announce.options[:adapter].to_s.camelize}Adapter::#{name.to_s.camelize}".constantize
end

.configure_broker(options) ⇒ Object



24
25
26
27
# File 'lib/announce/adapters/base_adapter.rb', line 24

def configure_broker(options)
  broker_manager = adapter_constantize(:broker_manager).new(options)
  broker_manager.configure
end

.publish(subject, action, body, options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/announce/adapters/base_adapter.rb', line 13

def publish(subject, action, body, options = {})
  topic = adapter_constantize(:topic).new(subject, action, options)
  msg = Announce::Message.new(subject: subject, action: action, body: body)
  topic.publish(msg.to_message, options)
end

.subscribe(worker_class, subject, actions = [], options = {}) ⇒ Object



19
20
21
22
# File 'lib/announce/adapters/base_adapter.rb', line 19

def subscribe(worker_class, subject, actions = [], options = {})
  subscriber = adapter_constantize(:subscriber).new
  subscriber.subscribe(worker_class, subject, actions, options)
end