Module: Mongoid::Sessions::Validators::Storage

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

Overview

Validates the options passed to :store_in.

Constant Summary collapse

VALID_OPTIONS =
[ :collection, :database, :session ]

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



21
22
23
24
25
# File 'lib/mongoid/sessions/validators/storage.rb', line 21

def validate(klass, options)
  if !options.is_a?(::Hash) || !valid_keys?(options)
    raise Errors::InvalidStorageOptions.new(klass, options)
  end
end