Class: DispatchRider::Publisher::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch-rider/publisher/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(publisher = nil) ⇒ Base

Returns a new instance of Base.



24
25
26
# File 'lib/dispatch-rider/publisher/base.rb', line 24

def initialize(publisher = nil)
  @publisher = publisher
end

Class Method Details

.default_publisherObject



14
15
16
# File 'lib/dispatch-rider/publisher/base.rb', line 14

def default_publisher
  @@default_publisher ||= DispatchRider::Publisher.new
end

.destinations(destinations) ⇒ Object



10
11
12
# File 'lib/dispatch-rider/publisher/base.rb', line 10

def destinations(destinations)
  @destinations = Array(destinations)
end

.publish(*args, &block) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/dispatch-rider/publisher/base.rb', line 18

def publish(*args, &block)
  raise NotImplementedError
end

.subject(subject) ⇒ Object



6
7
8
# File 'lib/dispatch-rider/publisher/base.rb', line 6

def subject(subject)
  @subject = subject
end

Instance Method Details

#publish(body) ⇒ Object



28
29
30
# File 'lib/dispatch-rider/publisher/base.rb', line 28

def publish(body)
  publisher.publish(destinations: destinations, message: { subject: subject, body: body })
end