123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Validatable::Queryable Private

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/mongoid/validatable/queryable.rb

Overview

TODO:

Move this into the Mongoid::Validatable::Uniqueness class.

Mixin module included in Mongoid::Validatable::Uniqueness class when ensures that the persistence context is cleared when executing uniqueness queries.

Instance Method Summary

  • #with_query(document) ⇒ Object Internal use only

    Wrap the validation inside the an execution block that alert’s the client not to clear its persistence options.

Instance Method Details

#with_query(document) ⇒ Object

Wrap the validation inside the an execution block that alert’s the client not to clear its persistence options.

Examples:

Execute the validation with a query.

with_query(document) do
  #...
end

Parameters:

  • document (Document)

    The document being validated.

Returns:

  • (Object)

    The result of the yield.

[ GitHub ]

  
# File 'lib/mongoid/validatable/queryable.rb', line 27

def with_query(document)
  klass = document.class
  begin
    Threaded.begin_execution("#{klass.name}-validate-with-query")
    yield
  ensure
    Threaded.exit_execution("#{klass.name}-validate-with-query")
  end
end