remove conditional code

This commit is contained in:
Sam 2018-06-08 13:38:25 +10:00
parent 1a00aaa825
commit 42847252a4

View File

@ -1,27 +1,24 @@
class ActiveRecord::ConnectionAdapters::AbstractAdapter
module LastUseExtension
attr_reader :last_use, :first_use
if Rails.version >= "4.2.0" def initialize(connection, logger = nil, pool = nil)
class ActiveRecord::ConnectionAdapters::AbstractAdapter super
module LastUseExtension @last_use = false
attr_reader :last_use, :first_use @first_use = Time.now
end
def initialize(connection, logger = nil, pool = nil) def lease
super @lock.synchronize do
@last_use = false unless in_use?
@first_use = Time.now @last_use = Time.now
end super
def lease
@lock.synchronize do
unless in_use?
@last_use = Time.now
super
end
end end
end end
end end
prepend LastUseExtension
end end
prepend LastUseExtension
end end
class ActiveRecord::ConnectionAdapters::ConnectionPool class ActiveRecord::ConnectionAdapters::ConnectionPool