123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Railties::ControllerRuntime

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: activerecord/lib/active_record/railties/controller_runtime.rb

Class Method Summary

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#db_runtime (rw, private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/railties/controller_runtime.rb', line 32

attr_internal :db_runtime

Instance Method Details

#append_info_to_payload(payload) (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/railties/controller_runtime.rb', line 56

def append_info_to_payload(payload)
  super

  payload[:db_runtime] = (db_runtime || 0) + ActiveRecord::RuntimeRegistry.reset_runtimes
  payload[:queries_count] = ActiveRecord::RuntimeRegistry.reset_queries_count
  payload[:cached_queries_count] = ActiveRecord::RuntimeRegistry.reset_cached_queries_count
end

#cleanup_view_runtime (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/railties/controller_runtime.rb', line 42

def cleanup_view_runtime
  if logger && logger.info?
    db_rt_before_render = ActiveRecord::RuntimeRegistry.reset_runtimes
    self.db_runtime = (db_runtime || 0) + db_rt_before_render
    runtime = super
    queries_rt = ActiveRecord::RuntimeRegistry.sql_runtime - ActiveRecord::RuntimeRegistry.async_sql_runtime
    db_rt_after_render = ActiveRecord::RuntimeRegistry.reset_runtimes
    self.db_runtime += db_rt_after_render
    runtime - queries_rt
  else
    super
  end
end

#initialize

[ GitHub ]

  
# File 'activerecord/lib/active_record/railties/controller_runtime.rb', line 26

def initialize(...) # :nodoc:
  super
  self.db_runtime = nil
end

#process_action(action, *args) (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/railties/controller_runtime.rb', line 34

def process_action(action, *args)
  # We also need to reset the runtime before each action
  # because of queries in middleware or in cases we are streaming
  # and it won't be cleaned up by the method below.
  ActiveRecord::RuntimeRegistry.reset
  super
end