Class: Untied::Event

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
lib/untied-consumer/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/untied-consumer/event.rb', line 9

def initialize(attrs)
  @config = {
    :name => "after_create",
    :payload => nil,
    :origin => nil
  }.merge(attrs)

  raise "You should inform the origin service" unless @config[:origin]

  @name = @config.delete(:name)
  @payload = @config.delete(:payload)
  @origin = @config.delete(:origin)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/untied-consumer/event.rb', line 7

def name
  @name
end

#originObject

Returns the value of attribute origin.



7
8
9
# File 'lib/untied-consumer/event.rb', line 7

def origin
  @origin
end

#payloadObject

Returns the value of attribute payload.



7
8
9
# File 'lib/untied-consumer/event.rb', line 7

def payload
  @payload
end

Instance Method Details

#attributesObject



23
24
25
# File 'lib/untied-consumer/event.rb', line 23

def attributes
  { "name" => @name, "origin" => @origin, "payload" => @payload }
end