Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing the sinatra example to use the better API

  • Loading branch information...
commit a885dfb865b77389e6959cf3f2522b97903cf9e1 1 parent 0dbe5c5
@julien51 julien51 authored
Showing with 9 additions and 6 deletions.
  1. +8 −6 examples/sinatra_app.rb
  2. +1 −0  lib/rack-superfeedr.rb
View
14 examples/sinatra_app.rb
@@ -2,7 +2,12 @@
require 'rack-superfeedr'
use Rack::Superfeedr, { :host => "plant-leg.showoff.io", :login => "demo", :password => "demo", :format => "json", :async => false } do |superfeedr|
- Superfeedr = superfeedr
+ set :superfeedr, superfeedr # so that we can use `settings.superfeedr` to access the superfeedr object in our application.
+
+ superfeedr.on_notification do |notification|
+ puts notification.to_s # You probably want to persist that data in some kind of data store...
+ end
+
end
get '/hi' do
@@ -10,13 +15,10 @@
end
get '/subscribe' do
- Superfeedr.subscribe("http://push-pub.appspot.com/feed")
+ settings.superfeedr.subscribe("http://push-pub.appspot.com/feed")
end
get '/unsubscribe' do
- Superfeedr.unsubscribe("http://push-pub.appspot.com/feed")
+ settings.superfeedr.unsubscribe("http://push-pub.appspot.com/feed")
end
-Superfeedr.on_notification do |notification|
- puts notification.to_s # You probably want to persist that data in some kind of data store...
-end
View
1  lib/rack-superfeedr.rb
@@ -87,6 +87,7 @@ def initialize(app, params = {}, &block)
@params = params
@app = app
block.call(self)
+ self
end
def call(env)
Please sign in to comment.
Something went wrong with that request. Please try again.