Permalink
Browse files

Accept a :printer option defaulting to :calltree.

  • Loading branch information...
1 parent ef24519 commit a12d587a078d3d5d96362ddddbdf7bc5543e3601 @jeremy jeremy committed Dec 10, 2008
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/rack/profiler.rb
View
@@ -23,9 +23,15 @@ class Profiler
RubyProf::CallTreePrinter => 'application/octet-stream'
}
- def initialize(app, printer = RubyProf::GraphHtmlPrinter)
+ # Accepts a :printer => [:calltree|:graphhtml|:graph|:flat] option
+ # defaulting to :calltree.
+ def initialize(app, options = {})
@app = app
- @printer = printer
+
+ @printer = options[:printer] || RubyProf::CallTreePrinter
+ unless @printer.is_a?(Class)
+ @printer = RubyProf.const_get("#{@printer.to_s.upcase}Printer")
+ end
end
def call(env)

0 comments on commit a12d587

Please sign in to comment.