Class: Hooksmith::Processor::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/hooksmith/processor/base.rb

Overview

This class is abstract.

Base class for all webhook processors.

Processors should inherit from this class and implement the process! method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Base

Initializes the processor with a payload.

Parameters:

  • payload (Hash)

    the webhook payload.



17
18
19
# File 'lib/hooksmith/processor/base.rb', line 17

def initialize(payload)
  @payload = payload
end

Instance Attribute Details

#payloadHash (readonly)

Returns the payload for the webhook.

Returns:

  • (Hash)

    the payload for the webhook.



12
13
14
# File 'lib/hooksmith/processor/base.rb', line 12

def payload
  @payload
end

Instance Method Details

#can_handle?(_payload) ⇒ Boolean

Checks if the processor can handle the payload. Override this method in subclasses if conditional processing is needed.

Parameters:

  • payload (Hash)

    the webhook payload.

Returns:

  • (Boolean)

    true if the processor can handle the payload.



26
27
28
# File 'lib/hooksmith/processor/base.rb', line 26

def can_handle?(_payload)
  true
end

#process!Object

Process the webhook. Must be implemented by subclasses.

Raises:

  • (NotImplementedError)

    if not implemented.



34
35
36
# File 'lib/hooksmith/processor/base.rb', line 34

def process!
  raise NotImplementedError, 'Implement process! in your processor'
end