class Warren::Message::Full

Generates a payload of an active_record object

Attributes

record[R]

Public Class Methods

new(record) click to toggle source
# File lib/warren/message/full.rb, line 9
def initialize(record)
  @record = record
end

Public Instance Methods

headers() click to toggle source

For compatibility. Returns an empty hash.

@return [{}] Empty hash

# File lib/warren/message/full.rb, line 41
def headers
  {}
end
payload() click to toggle source

The payload of the message. @see github.com/intridea/multi_json

@return [String] The message payload

# File lib/warren/message/full.rb, line 33
def payload
  MultiJson.dump(record)
end
routing_key() click to toggle source

The routing key that will be used for the message, not including the routing_key_prefix configured in warren.yml. If {#record} responds to `routing_key` will use that instead

@return [String] The routing key.

# File lib/warren/message/full.rb, line 20
def routing_key
  if record.respond_to?(:routing_key)
    record.routing_key
  else
    "saved.#{record.class.name.underscore}.#{record.id}"
  end
end