Module: Mongoid::Config::Validators::Client

Extended by:
Client
Included in:
Client
Defined in:
lib/mongoid/config/validators/client.rb

Overview

Validator for client specific configuration.

Constant Summary collapse

STANDARD =

Standard configuration options.

[ :database, :hosts, :username, :password ].freeze

Instance Method Summary collapse

Instance Method Details

#validate(clients) ⇒ Object

Validate the client configuration.

Examples:

Validate the client config.

Client.validate({ default: { hosts: [ "localhost:27017" ] }})

Parameters:

  • clients (Hash)

    The clients config.



21
22
23
24
25
26
27
28
29
30
# File 'lib/mongoid/config/validators/client.rb', line 21

def validate(clients)
  unless clients.has_key?(:default)
    raise Errors::NoDefaultClient.new(clients.keys)
  end
  clients.each_pair do |name, config|
    validate_client_database(name, config)
    validate_client_hosts(name, config)
    validate_client_uri(name, config)
  end
end