Module: Apress::Api::Callbacks::Integration::ClassMethods

Defined in:
lib/apress/api/callbacks/integration.rb

Instance Method Summary collapse

Instance Method Details

#notify_services(event:, params: {}, at:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/apress/api/callbacks/integration.rb', line 9

def notify_services(event:, params: {}, at:)
  at = Array.wrap(at)
  callback = at.shift

  public_send(callback, *at) do
    hash_params =
      if params.respond_to?(:call)
        params.call(self)
      else
        params.each_with_object({}) do |param, hash|
          hash[param] = public_send(param)
        end
      end
    ::Apress::Api::DelayedFireCallback.call!(event: event, params: hash_params)
  end
end