Sha256: 5b61d313ac7246bf7db8a427a2c949f2c74242ed19236e88b11f1f4b84847550
Contents?: true
Size: 937 Bytes
Versions: 6
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true module PubSubModelSync class Payload attr_reader :data, :attributes, :headers # @param data (Hash: { any value }): # @param attributes (Hash: { klass: string, action: :sym }): def initialize(data, attributes, headers = {}) @data = data @attributes = attributes @headers = headers build_headers end def to_h { data: data, attributes: attributes, headers: headers } end def klass attributes[:klass] end def action attributes[:action] end def process! publisher = PubSubModelSync::MessageProcessor.new(self) publisher.process end def publish! klass = PubSubModelSync::MessagePublisher klass.publish(self) end private def build_headers headers[:uuid] ||= SecureRandom.uuid headers[:app_key] ||= PubSubModelSync::Config.subscription_key end end end
Version data entries
6 entries across 6 versions & 1 rubygems