2015-09-11 14:41:01 +05:30
|
|
|
module AttrEncrypted
|
|
|
|
module Adapters
|
|
|
|
module ActiveRecord
|
2016-11-03 12:29:30 +05:30
|
|
|
module DBConnectionQuerier
|
|
|
|
def attribute_instance_methods_as_symbols
|
|
|
|
# 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
|
|
|
|
super
|
|
|
|
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
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
2016-11-03 12:29:30 +05:30
|
|
|
prepend DBConnectionQuerier
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|