Module: Mongoid::Clients::Validators::Storage

Extended by:
Storage
Included in:
Storage
Defined in:
lib/mongoid/clients/validators/storage.rb

Overview

Validates the options passed to :store_in.

Constant Summary collapse

VALID_OPTIONS =

The valid options for storage.

Since:

  • 3.0.0

[ :collection, :database, :client ].freeze

Instance Method Summary collapse

Instance Method Details

#validate(klass, options) ⇒ Object

Validate the options provided to :store_in.

Examples:

Validate the options.

Storage.validate(:collection_name)

Parameters:

  • klass (Class)

    The model class.

  • options (Hash, String, Symbol)

    The provided options.

Since:

  • 3.0.0



24
25
26
27
# File 'lib/mongoid/clients/validators/storage.rb', line 24

def validate(klass, options)
  valid_keys?(options) or raise Errors::InvalidStorageOptions.new(klass, options)
  valid_parent?(klass) or raise Errors::InvalidStorageParent.new(klass)
end