[Ruby-activeldap-commit] [ruby-activeldap commit] r761 - in trunk: lib/active_ldap/action_controller rails/plugin/active_ldap
codesite-noreply at google.com
codesite-noreply at google.com
Sat Jun 14 10:28:41 EDT 2008
Author: koutou
Date: Sat Jun 14 07:27:37 2008
New Revision: 761
Added:
trunk/lib/active_ldap/action_controller/
trunk/lib/active_ldap/action_controller/ldap_benchmarking.rb
Modified:
trunk/rails/plugin/active_ldap/init.rb
Log:
* modularize LDAP benchmarking.
Added: trunk/lib/active_ldap/action_controller/ldap_benchmarking.rb
==============================================================================
--- (empty file)
+++ trunk/lib/active_ldap/action_controller/ldap_benchmarking.rb Sat
Jun 14 07:27:37 2008
@@ -0,0 +1,36 @@
+module ActiveLdap
+ module ActionController
+ module LdapBenchmarking
+ def self.included(base)
+ base.class_eval do
+ alias_method_chain :render, :active_ldap_benchmark
+ alias_method_chain :rendering_runtime, :active_ldap
+ end
+ end
+
+ protected
+ def render_with_active_ldap_benchmark(*args, &block)
+ if logger
+ @ldap_runtime_before_render = ActiveLdap::Base.reset_runtime
+ result = render_without_active_ldap_benchmark(*args, &block)
+ @ldap_runtime_after_render = ActiveLdap::Base.reset_runtime
+ @rendering_runtime -= @ldap_runtime_after_render
+ result
+ else
+ render_without_active_ldap_benchmark(*args, &block)
+ end
+ end
+
+ private
+ def rendering_runtime_with_active_ldap(runtime)
+ result = rendering_runtime_without_active_ldap(runtime)
+ ldap_runtime = ActiveLdap::Base.reset_runtime
+ ldap_runtime += @ldap_runtime_before_render || 0
+ ldap_runtime += @ldap_runtime_after_render || 0
+ ldap_percentage = ldap_runtime * 100 / runtime
+ result + (" | LDAP: %.5f (%d%%)" % [ldap_runtime, ldap_percentage])
+ end
+ end
+ end
+end
+
Modified: trunk/rails/plugin/active_ldap/init.rb
==============================================================================
--- trunk/rails/plugin/active_ldap/init.rb (original)
+++ trunk/rails/plugin/active_ldap/init.rb Sat Jun 14 07:27:37 2008
@@ -1,7 +1,7 @@
require_library_or_gem 'active_ldap'
ActiveLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
-required_version = ["0", "10", "0"]
+required_version = ["1", "0", "0"]
if (ActiveLdap::VERSION.split(".") <=> required_version) < 0
ActiveLdap::Base.class_eval do
format = _("You need ActiveLdap %s or later")
@@ -25,40 +25,9 @@
include ActiveLdap::Helper
end
+require 'active_ldap/action_controller/ldap_benchmarking'
module ::ActionController
- module LdapBenchmarking
- def self.included(base)
- base.class_eval do
- alias_method_chain :render, :active_ldap_benchmark
- alias_method_chain :rendering_runtime, :active_ldap
- end
- end
-
- protected
- def render_with_active_ldap_benchmark(*args, &block)
- if logger
- @ldap_runtime_before_render = ActiveLdap::Base.reset_runtime
- result = render_without_active_ldap_benchmark(*args, &block)
- @ldap_runtime_after_render = ActiveLdap::Base.reset_runtime
- @rendering_runtime -= @ldap_runtime_after_render
- result
- else
- render_without_active_ldap_benchmark(*args, &block)
- end
- end
-
- private
- def rendering_runtime_with_active_ldap(runtime)
- result = rendering_runtime_without_active_ldap(runtime)
- ldap_runtime = ActiveLdap::Base.reset_runtime
- ldap_runtime += @ldap_runtime_before_render || 0
- ldap_runtime += @ldap_runtime_after_render || 0
- ldap_percentage = ldap_runtime * 100 / runtime
- result + (" | LDAP: %.5f (%d%%)" % [ldap_runtime, ldap_percentage])
- end
- end
-
class Base
- include LdapBenchmarking
+ include ActiveLdap::ActionController::LdapBenchmarking
end
end
More information about the Ruby-activeldap-commit
mailing list