Sha256: 8c9b1810418e928eb089a6fb405672b7b08e3e9dc44bdfa920dad74e970278b7

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true
module Apress
  module Api
    module Callbacks
      module Integration
        extend ActiveSupport::Concern

        module ClassMethods
          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
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apress-api-1.24.2 lib/apress/api/callbacks/integration.rb