Sha256: f5e7d8c7dc9ef6ed39d7e040a4b76b4e22d8523cb1d4274eacef67d261274138
Contents?: true
Size: 957 Bytes
Versions: 2
Compression:
Stored size: 957 Bytes
Contents
require 'securerandom' module DispatchRider class Publisher::Base class << self def subject(subject) @subject = subject end def destinations(destinations) @destinations = Array(destinations) end def default_publisher @@default_publisher ||= DispatchRider::Publisher.new end def publish(*args, &block) raise NotImplementedError end end def initialize(publisher = nil) @publisher = publisher end def publish(body) raise ArgumentError, 'body should be a hash' unless body.kind_of?(Hash) publisher.publish(destinations: destinations, message: { subject: subject, body: body }) end def publisher @publisher || self.class.default_publisher end def destinations self.class.instance_variable_get(:@destinations) end def subject self.class.instance_variable_get(:@subject) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dispatch-rider-1.4.2 | lib/dispatch-rider/publisher/base.rb |
dispatch-rider-1.4.0 | lib/dispatch-rider/publisher/base.rb |