README.md in stripe_event-1.0.0 vs README.md in stripe_event-1.1.0

- old
+ new

@@ -1,6 +1,7 @@ -# StripeEvent [![Build Status](https://secure.travis-ci.org/integrallis/stripe_event.png?branch=master)](http://travis-ci.org/integrallis/stripe_event) [![Dependency Status](https://gemnasium.com/integrallis/stripe_event.png)](https://gemnasium.com/integrallis/stripe_event) [![Gem Version](https://badge.fury.io/rb/stripe_event.png)](http://badge.fury.io/rb/stripe_event) +# StripeEvent +[![Build Status](https://secure.travis-ci.org/integrallis/stripe_event.png?branch=master)](http://travis-ci.org/integrallis/stripe_event) [![Dependency Status](https://gemnasium.com/integrallis/stripe_event.png)](https://gemnasium.com/integrallis/stripe_event) [![Gem Version](https://badge.fury.io/rb/stripe_event.png)](http://badge.fury.io/rb/stripe_event) [![Code Climate](https://codeclimate.com/github/integrallis/stripe_event.png)](https://codeclimate.com/github/integrallis/stripe_event) [![Coverage Status](https://coveralls.io/repos/integrallis/stripe_event/badge.png)](https://coveralls.io/r/integrallis/stripe_event) StripeEvent is built on the [ActiveSupport::Notifications API](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html). Incoming webhook requests are authenticated by [retrieving the event object](https://stripe.com/docs/api?lang=ruby#retrieve_event) from Stripe. Define subscribers to handle a single event type or all event types. Subscribers can be a block or any object that responds to `#call`. ## Install @@ -18,19 +19,19 @@ ```ruby # config/initializers/stripe.rb Stripe.api_key = ENV['STRIPE_API_KEY'] # Set your api key -StripeEvent.setup do - subscribe 'charge.failed' do |event| +StripeEvent.configure do |events| + events.subscribe 'charge.failed' do |event| # Define subscriber behavior based on the event object event.class #=> Stripe::Event event.type #=> "charge.failed" event.data.object #=> #<Stripe::Charge:0x3fcb34c115f8> end - all do |event| + events.all do |event| # Handle all event types - logging, etc. end end # Subscriber objects that respond to #call @@ -52,12 +53,18 @@ def call(event) @logger.info "BILLING-EVENT: #{event.type} #{event.id}" end end -StripeEvent.setup do - all BillingEventLogger.new(Rails.logger) - subscribe 'customer.created', CustomerCreated.new +StripeEvent.configure do |events| + events.all BillingEventLogger.new(Rails.logger) + events.subscribe 'customer.created', CustomerCreated.new +end + +# Subscribing to a namespace of event types + +StripeEvent.subscribe 'customer.card.' do |event| + # Will be triggered for any customer.card.* events end ``` ## Configuration