Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit d2b76cae929f612a36faf34979552617e3d10850 1 parent baaf3b4
@daddz daddz authored
View
4 config.ru
@@ -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
8 lib/bar.rb
@@ -12,8 +12,8 @@ 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'
@@ -21,8 +21,8 @@ class Bar < Sinatra::Base
## app
## end
- def self.app
- Foobar::Bar.new
+ def self.new(*)
+ super
end
end
View
8 lib/foo.rb
@@ -12,8 +12,8 @@ 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'
@@ -21,8 +21,8 @@ class Foo < Sinatra::Base
## app
## end
- def self.app
- Foobar::Foo.new
+ def self.new(*)
+ super
end
end
View
2  spec/bar_spec.rb
@@ -3,7 +3,7 @@
describe Foobar::Bar do
def app
- @app ||= Foobar::Bar.app
+ @app ||= Foobar::Bar
end
describe "GET '/'" do
View
2  spec/foo_spec.rb
@@ -3,7 +3,7 @@
describe Foobar::Foo do
def app
- @app ||= Foobar::Foo.app
+ @app ||= Foobar::Foo
end
describe "GET '/'" do
Please sign in to comment.
Something went wrong with that request. Please try again.