Class: StackTracy::Sinatra
- Inherits:
-
Object
- Object
- StackTracy::Sinatra
- Defined in:
- lib/stack_tracy/sinatra.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, arg = nil, options = {}, &before_filter) ⇒ Sinatra
constructor
A new instance of Sinatra.
Constructor Details
#initialize(app, arg = nil, options = {}, &before_filter) ⇒ Sinatra
Returns a new instance of Sinatra.
4 5 6 7 8 9 |
# File 'lib/stack_tracy/sinatra.rb', line 4 def initialize(app, arg = nil, = {}, &before_filter) @app = app @arg = arg @options = @before_filter = before_filter if block_given? end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stack_tracy/sinatra.rb', line 11 def call(env) request = ::Sinatra::Request.new env if request.path.match /^\/tracy(-.*)?/ return open($1.to_s.gsub(/^-/, "")) end if @before_filter.nil? || !!@before_filter.call(request.path, request.params) result = nil stack_tracy @arg || Dir::tmpdir, @options do result = @app.call(env) end result else @app.call(env) end end |