Sha256: 73c7c95ba4f0db5abd57878ead938166c1385aa2ffd10f32887e63a0086031d4
Contents?: true
Size: 739 Bytes
Versions: 11
Compression:
Stored size: 739 Bytes
Contents
module StripeLocal module Webhook # # basically taken straight from the StripeEvents gem # https://github.com/integrallis/stripe_event # # class Subscriber def initialize *names, &block @names = names @block = block ensure_valid_types! end def register ActiveSupport::Notifications.subscribe(pattern) do |_, _, _, _, payload| @block.call payload[:event] end end private def pattern Regexp.union(@names.empty? ? TYPE_LIST : @names) end def ensure_valid_types! invalid_names = @names.select { |name| !TYPE_LIST.include?(name) } raise InvalidEventType.new(invalid_names) if invalid_names.any? end end end end
Version data entries
11 entries across 11 versions & 1 rubygems