Class: ConsoleKit::Connections::MongoConnectionHandler

Inherits:
BaseConnectionHandler show all
Extended by:
Forwardable
Defined in:
lib/console_kit/connections/mongo_connection_handler.rb

Overview

Handles MongoDB connections

Instance Attribute Summary

Attributes inherited from BaseConnectionHandler

#context

Instance Method Summary collapse

Methods inherited from BaseConnectionHandler

#initialize

Constructor Details

This class inherits a constructor from ConsoleKit::Connections::BaseConnectionHandler

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


23
# File 'lib/console_kit/connections/mongo_connection_handler.rb', line 23

def available? = defined?(Mongoid)

#connectObject



14
15
16
17
18
19
20
21
# File 'lib/console_kit/connections/mongo_connection_handler.rb', line 14

def connect
  return if tenant_mongo_db.blank?

  Output.print_info("Switching to MongoDB client: #{tenant_mongo_db}")
  Mongoid.override_client(tenant_mongo_db)
rescue NoMethodError
  Output.print_warning('Mongoid.override_client is not defined.')
end