Class: Marginalia::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- Marginalia::Railtie
- Defined in:
- lib/marginalia/railtie.rb
Class Method Summary collapse
- .insert ⇒ Object
- .insert_into_action_controller ⇒ Object
- .insert_into_active_job ⇒ Object
- .insert_into_active_record ⇒ Object
Class Method Details
.insert ⇒ Object
20 21 22 23 24 |
# File 'lib/marginalia/railtie.rb', line 20 def self.insert insert_into_active_record insert_into_action_controller insert_into_active_job end |
.insert_into_action_controller ⇒ Object
41 42 43 44 45 46 |
# File 'lib/marginalia/railtie.rb', line 41 def self.insert_into_action_controller ActionController::Base.send(:include, ActionControllerInstrumentation) if defined? ActionController::API ActionController::API.send(:include, ActionControllerInstrumentation) end end |
.insert_into_active_job ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/marginalia/railtie.rb', line 26 def self.insert_into_active_job if defined? ActiveJob::Base ActiveJob::Base.class_eval do around_perform do |job, block| begin Marginalia::Comment.update_job! job block.call ensure Marginalia::Comment.clear_job! end end end end end |
.insert_into_active_record ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/marginalia/railtie.rb', line 48 def self.insert_into_active_record if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter ActiveRecord::ConnectionAdapters::Mysql2Adapter.module_eval do include Marginalia::ActiveRecordInstrumentation end end if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do include Marginalia::ActiveRecordInstrumentation end end if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.module_eval do include Marginalia::ActiveRecordInstrumentation end end if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter ActiveRecord::ConnectionAdapters::SQLite3Adapter.module_eval do include Marginalia::ActiveRecordInstrumentation end end end |