Module: AfterCommit::AfterSavepoint

Defined in:
lib/after_commit/after_savepoint.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/after_commit/after_savepoint.rb', line 7

def self.included(klass)
  klass.class_eval do
    class << self
      def include_after_savepoint_extensions
        base = ::ActiveRecord::ConnectionAdapters::AbstractAdapter
        Object.subclasses_of(base).each do |klass|
          include_after_savepoint_extension klass
        end
    
        if defined?(JRUBY_VERSION) and defined?(JdbcSpec::MySQL)
          include_after_savepoint_extension JdbcSpec::MySQL
        end
      end

      private
  
      def include_after_savepoint_extension(adapter)
        additions = AfterCommit::TestConnectionAdapters
        unless adapter.included_modules.include?(additions)
          adapter.send :include, additions
        end
      end
    end
  end
end