Class: WebhookSystem::BaseEvent

Inherits:
Object
  • Object
show all
Includes:
PhModel
Defined in:
lib/webhook_system/base_event.rb

Overview

This is the class meant to be used as the base class for any Events sent through the Webhook system

Instance Method Summary collapse

Instance Method Details

#as_json ⇒ Object



17
18
19
20
21
22
23
# File 'lib/webhook_system/base_event.rb', line 17

def as_json
  result = { 'event' => event_name }
  each_attribute do |attribute_name, attribute_method|
    result[attribute_name.to_s] = public_send(attribute_method).as_json
  end
  result
end

#event_name ⇒ Object



7
8
9
10
# File 'lib/webhook_system/base_event.rb', line 7

def event_name
  mesg = "class #{self.class.name} must implement abstract method `#{self.class.name}#event_name()'."
  raise RuntimeError.new(mesg).tap { |err| err.backtrace = caller }
end

#payload_attributes ⇒ Object



12
13
14
15
# File 'lib/webhook_system/base_event.rb', line 12

def payload_attributes
  mesg = "class #{self.class.name} must implement abstract method `#{self.class.name}#payload_attributes()'."
  raise RuntimeError.new(mesg).tap { |err| err.backtrace = caller }
end