Class: Moneta::Adapters::ActiveRecord::Backend Private
- Inherits:
-
Object
- Object
- Moneta::Adapters::ActiveRecord::Backend
- Defined in:
- lib/moneta/adapters/activerecord/backend.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Attribute Summary collapse
- .connection_lock ⇒ Object readonly private
Instance Attribute Summary collapse
- #table_name ⇒ Object readonly private
Instance Method Summary collapse
- #connection_pool ⇒ Object private
-
#initialize(table:, connection: nil, **options) ⇒ Backend
constructor
private
A new instance of Backend.
Constructor Details
#initialize(table:, connection: nil, **options) ⇒ Backend
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Backend.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/moneta/adapters/activerecord/backend.rb', line 17 def initialize(table:, connection: nil, **) @table_name = table @connection = connection if connection @owner_name = case connection when Symbol, String connection.to_s when Hash hash = connection.reject { |key| [:username, 'username', :password, 'password'].member?(key) } 'moneta?' + URI.encode_www_form(hash.to_a.sort) when nil nil else raise "Unexpected connection: #{connection}" end end end |
Class Attribute Details
.connection_lock ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/moneta/adapters/activerecord/backend.rb', line 11 def connection_lock @connection_lock end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/moneta/adapters/activerecord/backend.rb', line 14 def table_name @table_name end |
Instance Method Details
#connection_pool ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/moneta/adapters/activerecord/backend.rb', line 36 def connection_pool if @connection connection_handler.retrieve_connection_pool(@owner_name) || self.class.connection_lock.synchronize do connection_handler.retrieve_connection_pool(@owner_name) || connection_handler.establish_connection(@connection, owner_name: @owner_name) end else ::ActiveRecord::Base.connection_pool end end |