Sha256: 0e1053f9719ab75ed9fc3948227ffc6c2ef4a646ac7ab03404b135336279746d

Contents?: true

Size: 618 Bytes

Versions: 5

Compression:

Stored size: 618 Bytes

Contents

module ActiveRecord
  # rubocop:disable Style/ClassVars
  # Rubocop is wrong about these being needed: they are needed because when
  # changed to class-level instance variables the connection isn't really
  # shared.
  class Base
    mattr_accessor :shared_connection
    @@shared_connection = nil

    def self.connection
      @@shared_connection || retrieve_connection
    end
  end
  # rubocop:enable Style/ClassVars
end

# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message_train-0.7.6 spec/support/shared_connection.rb
message_train-0.7.5 spec/support/shared_connection.rb
message_train-0.7.3 spec/support/shared_connection.rb
message_train-0.7.2 spec/support/shared_connection.rb
message_train-0.7.1 spec/support/shared_connection.rb