Permalink
Browse files

allow instruments option to middleware to take a single argument in a…

…ddition to array
  • Loading branch information...
1 parent dce25d0 commit 9b7bb2e7682be4444120f2500cc9f86a76b95781 Eirik Dentz Sinclair & Noah Davis committed Apr 6, 2011
Showing with 6 additions and 6 deletions.
  1. +2 −2 README.rdoc
  2. +2 −2 lib/oink/middleware.rb
  3. +2 −2 spec/oink/middleware_configuration_spec.rb
View
@@ -56,11 +56,11 @@ Oink::Middleware logs memory and activerecord usage by default.
You can configure which using the :instruments option. For memory only:
- YourApplication::Application.middleware.use( Oink::Middleware, :instruments => [:memory] )
+ YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :memory )
For activerecord instantiation counts only:
- YourApplication::Application.middleware.use( Oink::Middleware, :instruments => [:activerecord] )
+ YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :activerecord )
Note that the previous way of configuring oink, as a set of modules to include into rails controllers, is deprecated.
@@ -7,8 +7,8 @@ class Middleware
def initialize(app, options = {})
@app = app
- @logger = options[:logger] || Hodel3000CompliantLogger.new("log/oink.log")
- @instruments = options[:instruments] || [:memory, :activerecord]
+ @logger = options[:logger] || Hodel3000CompliantLogger.new("log/oink.log")
+ @instruments = options[:instruments] ? Array(options[:instruments]) : [:memory, :activerecord]
ActiveRecord::Base.send(:include, Oink::Instrumentation::ActiveRecord) if @instruments.include?(:activerecord)
end
@@ -23,7 +23,7 @@ def call(env)
context "with the memory instrument specified" do
before do
- @oink_configuration = { :instruments => [:memory] }
+ @oink_configuration = { :instruments => :memory }
end
it "does log memory usage" do
@@ -49,7 +49,7 @@ def call(env)
context "with the activerecord instrument specified" do
before do
- @oink_configuration = { :instruments => [:activerecord] }
+ @oink_configuration = { :instruments => :activerecord }
get "/"
end

0 comments on commit 9b7bb2e

Please sign in to comment.