module ActivePubsub::Publishable::ClassMethods

Public Instance Methods

exchange_key() click to toggle source
# File lib/active_pubsub/publishable.rb, line 59
def exchange_key
  [
    try(:exchange_prefix) { ::ActivePubsub.config.try(:publish_as) },
    name.demodulize.underscore
  ].flatten.compact.join(".")
end
publish_as(prefix) click to toggle source

this is the publishing service namespace which will be used to build exchange name

# File lib/active_pubsub/publishable.rb, line 68
def publish_as(prefix)
  self.exchange_prefix = prefix

  ::ActivePubsub::Publisher.start unless ::ActivePubsub::Publisher.started

  ::ActivePubsub.publisher.register_exchange(exchange_key)
end
publishable_actions(*actions) click to toggle source

todo: make publishable actions filterable/appendable

# File lib/active_pubsub/publishable.rb, line 77
def publishable_actions(*actions)
  @publishable_actions = actions
end
resource_routing_keys() click to toggle source
# File lib/active_pubsub/publishable.rb, line 85
def resource_routing_keys
  [try(:exchange_prefix), name.demodulize.underscore].flatten.compact
end
routing_key() click to toggle source
# File lib/active_pubsub/publishable.rb, line 81
def routing_key
  resource_routing_keys.join(".")
end