lib/remnant/rails.rb in remnant-0.2.4 vs lib/remnant/rails.rb in remnant-0.3.0
- old
+ new
@@ -36,9 +36,43 @@
Remnant::Discover.find('filters', ActionController::Filters::BeforeFilter, :call)
Remnant::Discover.find('action', ActionController::Base, :perform_action)
Remnant::Discover.find('view', ActionController::Base, :render)
Remnant::Discover.find('filters', ActionController::Filters::AfterFilter, :call)
+ #
+ # Template rendering
+ #
+ if defined?(ActionView) && defined?(ActionView::Template)
+ Remnant::Discover.find_with(ActionView::Template) do
+ ActionView::Template.class_eval do
+ def render_template_with_remnant(*args, &block)
+ ::Remnant::Template.record(path_without_format_and_extension) do
+ render_template_without_remnant(*args, &block)
+ end
+ end
+
+ alias_method_chain :render_template, :remnant
+ end
+ end
+ end
+
+ #
+ # database query time
+ #
+ if ::Rails::VERSION::MAJOR == 2
+ Remnant::Discover.find_with(ActiveRecord::ConnectionAdapters::AbstractAdapter) do
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
+ def log_with_remnant(sql, name, &block)
+ ::Remnant::Database.record(sql, Kernel.caller) do
+ log_without_remnant(sql, name, &block)
+ end
+ end
+
+ alias_method_chain :log, :remnant
+ end
+ end
+ end
+
# last hook into request cycle for sending results
::ActionController::Dispatcher.class_eval do
def call_with_remnant_discovery(*args, &block) #:nodoc:
call_without_remnant_discovery(*args, &block).tap do |status, headers, response|
begin