Sha256: f9c32b22778dc2e8d410c075bfdbb1fb8a64e53a6f2b2bf002790e4c10d92449
Contents?: true
Size: 885 Bytes
Versions: 5
Compression:
Stored size: 885 Bytes
Contents
# -*- encoding : utf-8 -*- module Untied class Event attr_accessor :name, :payload, :origin def initialize(attrs) @config = { :name => "after_create", :payload => nil, :origin => nil, :payload_representer => nil }.merge(attrs) raise "You should inform the origin service" unless @config[:origin] @name = @config.delete(:name) @payload = represent(@config.delete(:payload)) @origin = @config.delete(:origin) self.extend(Publisher::EventRepresenter) end protected # Extends payload with representer and returns the hash. In cases there is # no representer, the raw payload is returned def represent(payload) if representer = @config[:payload_representer] payload.extend(representer) payload.to_hash else payload end end end end
Version data entries
5 entries across 5 versions & 1 rubygems