Class: StripeLocal::Webhook::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/stripe_local/webhook/subscriber.rb

Overview

basically taken straight from the StripeEvents gem github.com/integrallis/stripe_event

Instance Method Summary collapse

Constructor Details

#initialize(*names, &block) ⇒ Subscriber

Returns a new instance of Subscriber.



10
11
12
13
14
# File 'lib/stripe_local/webhook/subscriber.rb', line 10

def initialize *names, &block
  @names = names
  @block = block
  ensure_valid_types!
end

Instance Method Details

#registerObject



16
17
18
19
20
# File 'lib/stripe_local/webhook/subscriber.rb', line 16

def register
  ActiveSupport::Notifications.subscribe(pattern) do |_, _, _, _, payload|
    @block.call payload[:event]
  end
end