mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 04:36:11 +10:00
Merge branch 'attr_encryped_no_db_connection' into 'master'
Don't require DB connection in AttrEncrypted. See merge request !667
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
module AttrEncrypted
|
||||
module Adapters
|
||||
module ActiveRecord
|
||||
def attribute_instance_methods_as_symbols_with_no_db_connection
|
||||
# Use with_connection so the connection doesn't stay pinned to the thread.
|
||||
connected = ::ActiveRecord::Base.connection_pool.with_connection(&:active?) rescue false
|
||||
|
||||
if connected
|
||||
# Call version from AttrEncrypted::Adapters::ActiveRecord
|
||||
attribute_instance_methods_as_symbols_without_no_db_connection
|
||||
else
|
||||
# Call version from AttrEncrypted, i.e., `super` with regards to AttrEncrypted::Adapters::ActiveRecord
|
||||
AttrEncrypted.instance_method(:attribute_instance_methods_as_symbols).bind(self).call
|
||||
end
|
||||
end
|
||||
|
||||
alias_method_chain :attribute_instance_methods_as_symbols, :no_db_connection
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user