module ActivePubsub::Publishable

Constants

PUBLISHABLE_ACTIONS

Public Instance Methods

attributes_hash() click to toggle source

todo: investigate why specs break if && hash is omitted

# File lib/active_pubsub/publishable.rb, line 21
def attributes_hash
  hash = self.as_json
  hash.merge!(:changes => previous_changes) if previous_changes && hash
  hash.symbolize_keys! if hash
  hash
end

Private Instance Methods

publish_created_event() click to toggle source
# File lib/active_pubsub/publishable.rb, line 38
def publish_created_event
  record_created_event = ::ActivePubsub::Event.new(self.class.exchange_key, "created", serialized_resource)

  ::ActivePubsub.publish_event(record_created_event)

  ::ActivePubsub.logger.info(record_created_event)
end
publish_destroyed_event() click to toggle source
# File lib/active_pubsub/publishable.rb, line 46
def publish_destroyed_event
  record_destroyed_event = ::ActivePubsub::Event.new(self.class.exchange_key, "destroyed", serialized_resource)

  ::ActivePubsub.publish_event(record_destroyed_event)

  ::ActivePubsub.logger.info(record_destroyed_event)
end
publish_updated_event() click to toggle source
# File lib/active_pubsub/publishable.rb, line 30
def publish_updated_event
  record_updated_event = ::ActivePubsub::Event.new(self.class.exchange_key, "updated", serialized_resource)

  ::ActivePubsub.publish_event(record_updated_event)

  ::ActivePubsub.logger.info(record_updated_event)
end
serialized_resource() click to toggle source
# File lib/active_pubsub/publishable.rb, line 54
def serialized_resource
  Marshal.dump(attributes_hash)
end