Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
show all
- Defined in:
- lib/aws_sqs_moniter/monkey_patches/forbid_implicit_active_record_connection_checkout.rb
Class Method Summary
collapse
Class Method Details
.connection_with_forbid_implicit(*args, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/aws_sqs_moniter/monkey_patches/forbid_implicit_active_record_connection_checkout.rb', line 12
def connection_with_forbid_implicit(*args, &block)
if implicit_checkout_forbidden? && !connection_handler.retrieve_connection_pool(self).active_connection?
message = 'Implicit ActiveRecord checkout attempted when Thread :force_explicit_connections set!'
$stderr.puts(message) if Rails.env.test?
fail ImplicitConnectionForbiddenError, message
end
connection_without_forbid_implicit(*args, &block)
end
|
.forbid_implicit_checkout! ⇒ Object
4
5
6
|
# File 'lib/aws_sqs_moniter/monkey_patches/forbid_implicit_active_record_connection_checkout.rb', line 4
def forbid_implicit_checkout!
Thread.current[:active_record_forbid_implicit_connections] = true
end
|
.implicit_checkout_forbidden? ⇒ Boolean
8
9
10
|
# File 'lib/aws_sqs_moniter/monkey_patches/forbid_implicit_active_record_connection_checkout.rb', line 8
def implicit_checkout_forbidden?
!!Thread.current[:active_record_forbid_implicit_connections]
end
|