Class: ResourceSubscriber::Publisher

Inherits:
Object
  • Object
show all
Includes:
AutoInject
Defined in:
lib/resource_subscriber/publisher.rb

Instance Method Summary collapse

Methods included from AutoInject

#initialize

Instance Method Details

#publish_as(routing_key) {|self.config| ... } ⇒ Object

Yields:

  • (self.config)


12
13
14
15
# File 'lib/resource_subscriber/publisher.rb', line 12

def publish_as(routing_key)
  yield(self.config) if block_given?
  self.config.routing_key = routing_key
end

#publish_resource_message(action, resource) ⇒ Object



7
8
9
10
# File 'lib/resource_subscriber/publisher.rb', line 7

def publish_resource_message(action, resource)
  message = ::ResourceSubscriber::Message.new(resource)
  ::ActionSubscriber::Publisher.publish_async("#{self.config.routing_key}.#{action}", message.to_json, self.config.exchange, self.config.publishing_options)
end