Module: Motel::ActiveRecord::ConnectionHandler::ClassMethods
- Defined in:
- lib/motel/active_record/connection_handler.rb
Instance Method Summary collapse
- #arel_engine ⇒ Object
- #connected? ⇒ Boolean
- #connection_pool ⇒ Object
- #current_tenant ⇒ Object
- #establish_connection(config) ⇒ Object
- #remove_connection(tenant_name = current_tenant) ⇒ Object
- #retrieve_connection ⇒ Object
Instance Method Details
#arel_engine ⇒ Object
48 49 50 |
# File 'lib/motel/active_record/connection_handler.rb', line 48 def arel_engine ::ActiveRecord::Base end |
#connected? ⇒ Boolean
40 41 42 |
# File 'lib/motel/active_record/connection_handler.rb', line 40 def connected? connection_handler.connected?(current_tenant) end |
#connection_pool ⇒ Object
32 33 34 |
# File 'lib/motel/active_record/connection_handler.rb', line 32 def connection_pool connection_handler.retrieve_connection_pool(current_tenant) end |
#current_tenant ⇒ Object
52 53 54 |
# File 'lib/motel/active_record/connection_handler.rb', line 52 def current_tenant Motel::Manager.current_tenant or raise Motel::NoCurrentTenantError end |
#establish_connection(config) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/motel/active_record/connection_handler.rb', line 18 def establish_connection(config) case config when String, Symbol tenant_name = config.to_s spec = nil else tenant_name = current_tenant resolver = Motel::ConnectionAdapters::ConnectionSpecification::Resolver.new spec = resolver.spec(config) end connection_handler.establish_connection tenant_name, spec end |
#remove_connection(tenant_name = current_tenant) ⇒ Object
44 45 46 |
# File 'lib/motel/active_record/connection_handler.rb', line 44 def remove_connection(tenant_name = current_tenant) connection_handler.remove_connection(tenant_name) end |
#retrieve_connection ⇒ Object
36 37 38 |
# File 'lib/motel/active_record/connection_handler.rb', line 36 def retrieve_connection connection_handler.retrieve_connection(current_tenant) end |