lib/stripe_event/subscriber.rb in stripe_event-0.2.0 vs lib/stripe_event/subscriber.rb in stripe_event-0.3.0

- old
+ new

@@ -1,9 +1,9 @@ module StripeEvent class Subscriber - def initialize(names, &block) - @names = Array(names) + def initialize(*names, &block) + @names = names @block = block ensure_valid_types! end def register @@ -11,20 +11,20 @@ end private def pattern - Regexp.union(@names.empty? ? TYPES : @names) + Regexp.union(@names.empty? ? TYPE_LIST : @names) end def proxied_block lambda do |name, started, finished, id, payload| @block.call(payload[:event]) end end def ensure_valid_types! - invalid_names = @names.select { |name| !TYPES.include?(name) } + invalid_names = @names.select { |name| !TYPE_LIST.include?(name) } raise InvalidEventType.new(invalid_names) if invalid_names.any? end end end