First pass
This commit is contained in:
commit
47c4efa44c
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.gem
|
||||
.bundle
|
||||
Gemfile.lock
|
||||
pkg/*
|
4
Gemfile
Normal file
4
Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
# Specify your gem's dependencies in controller_filter_logging.gemspec
|
||||
gemspec
|
21
controller_filter_logging.gemspec
Normal file
21
controller_filter_logging.gemspec
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require "controller_filter_logging/version"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "controller_filter_logging"
|
||||
s.version = ControllerFilterLogging::VERSION
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.authors = ["Jon Moses"]
|
||||
s.email = ["jon@burningbush.us"]
|
||||
s.homepage = ""
|
||||
s.summary = %q{Bring back controller filter logging to rails 3}
|
||||
s.description = %q{Gem to log execution and results of before_filter's for Rails 3}
|
||||
|
||||
s.rubyforge_project = "controller_filter_logging"
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.require_paths = ["lib"]
|
||||
end
|
1
init.rb
Normal file
1
init.rb
Normal file
@ -0,0 +1 @@
|
||||
require 'lib/controller_filter_logging' unless Rails.env.production?
|
27
lib/controller_filter_logging.rb
Normal file
27
lib/controller_filter_logging.rb
Normal file
@ -0,0 +1,27 @@
|
||||
module AbstractController::Callbacks::ClassMethods
|
||||
def before_filter_with_logging(filter_name, *args)
|
||||
create_logging_filter(filter_name)
|
||||
before_filter_without_logging "#{filter_name}_with_logging".to_sym, *args
|
||||
end
|
||||
alias_method_chain :before_filter, :logging
|
||||
|
||||
def skip_before_filter_with_logging(filter_name, *args)
|
||||
skip_before_filter_without_logging("#{filter_name}_with_logging".to_sym, *args)
|
||||
end
|
||||
alias_method_chain :skip_before_filter, :logging
|
||||
|
||||
def prepend_before_filter_with_logging(filter_name, *args)
|
||||
create_logging_filter(filter_name)
|
||||
prepend_before_filter_without_logging("#{filter_name}_with_logging".to_sym, *args)
|
||||
end
|
||||
alias_method_chain :prepend_before_filter, :logging
|
||||
|
||||
def create_logging_filter(filter_name)
|
||||
define_method("#{filter_name}_with_logging") do
|
||||
Rails.logger.debug("Entering before_filter: #{filter_name}")
|
||||
send(filter_name).tap do |result|
|
||||
Rails.logger.debug(" result: #{result}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
lib/controller_filter_logging/version.rb
Normal file
3
lib/controller_filter_logging/version.rb
Normal file
@ -0,0 +1,3 @@
|
||||
module ControllerFilterLogging
|
||||
VERSION = "0.0.1"
|
||||
end
|
Loading…
Reference in New Issue
Block a user