Permalink
Browse files

override new rather than defining app, this is way better, thanks to rkh

  • Loading branch information...
1 parent baaf3b4 commit d2b76cae929f612a36faf34979552617e3d10850 @daddz committed Mar 18, 2011
Showing with 12 additions and 12 deletions.
  1. +2 −2 config.ru
  2. +4 −4 lib/bar.rb
  3. +4 −4 lib/foo.rb
  4. +1 −1 spec/bar_spec.rb
  5. +1 −1 spec/foo_spec.rb
View
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/config/boot.rb'
run Rack::URLMap.new({
- "/" => Foobar::Foo.new,
- "/bar" => Foobar::Bar.new
+ "/" => Foobar::Foo,
+ "/bar" => Foobar::Bar
})
View
@@ -12,17 +12,17 @@ class Bar < Sinatra::Base
# I did this to be able to wrap my app in Rack::Auth::Digest for example
## Example:
- ## def self.app
- ## app = Rack::Auth::Digest::MD5.new(Historiously::Api.new) do |username|
+ ## def self.new(*)
+ ## app = Rack::Auth::Digest::MD5.new(super) do |username|
## {'foo' => 'bar'}[username]
## end
## app.realm = 'Foobar::Bar'
## app.opaque = 'secretstuff'
## app
## end
- def self.app
- Foobar::Bar.new
+ def self.new(*)
+ super
end
end
View
@@ -12,17 +12,17 @@ class Foo < Sinatra::Base
# I did this to be able to wrap my app in Rack::Auth::Digest for example
## Example:
- ## def self.app
- ## app = Rack::Auth::Digest::MD5.new(Historiously::Api.new) do |username|
+ ## def self.new(*)
+ ## app = Rack::Auth::Digest::MD5.new(super) do |username|
## {'foo' => 'bar'}[username]
## end
## app.realm = 'Foobar::Foo'
## app.opaque = 'secretstuff'
## app
## end
- def self.app
- Foobar::Foo.new
+ def self.new(*)
+ super
end
end
View
@@ -3,7 +3,7 @@
describe Foobar::Bar do
def app
- @app ||= Foobar::Bar.app
+ @app ||= Foobar::Bar
end
describe "GET '/'" do
View
@@ -3,7 +3,7 @@
describe Foobar::Foo do
def app
- @app ||= Foobar::Foo.app
+ @app ||= Foobar::Foo
end
describe "GET '/'" do

0 comments on commit d2b76ca

Please sign in to comment.