Sha256: ece5392df215caef714d5115f414f60d7573faeb6ff6d72ad8a3ac5b1c58b48e

Contents?: true

Size: 769 Bytes

Versions: 24

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module Mongoid
  module Validatable
    module Queryable

      # Wrap the validation inside the an execution block that alert's the
      # client not to clear its persistence options.
      #
      # @example Execute the validation with a query.
      #   with_query(document) do
      #     #...
      #   end
      #
      # @param [ Document ] document The document being validated.
      #
      # @return [ Object ] The result of the yield.
      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
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-8.1.7 lib/mongoid/validatable/queryable.rb
mongoid-8.1.6 lib/mongoid/validatable/queryable.rb
mongoid-8.0.8 lib/mongoid/validatable/queryable.rb
mongoid-8.1.5 lib/mongoid/validatable/queryable.rb
mongoid-8.1.4 lib/mongoid/validatable/queryable.rb
mongoid-8.0.7 lib/mongoid/validatable/queryable.rb
mongoid-8.1.3 lib/mongoid/validatable/queryable.rb
mongoid-8.1.2 lib/mongoid/validatable/queryable.rb
mongoid-8.0.6 lib/mongoid/validatable/queryable.rb
mongoid-7.5.4 lib/mongoid/validatable/queryable.rb
mongoid-8.1.1 lib/mongoid/validatable/queryable.rb
mongoid-8.0.5 lib/mongoid/validatable/queryable.rb
mongoid-8.1.0 lib/mongoid/validatable/queryable.rb
mongoid-7.5.3 lib/mongoid/validatable/queryable.rb
mongoid-8.0.4 lib/mongoid/validatable/queryable.rb
mongoid-8.0.3 lib/mongoid/validatable/queryable.rb
mongoid-7.5.2 lib/mongoid/validatable/queryable.rb
mongoid-8.0.2 lib/mongoid/validatable/queryable.rb
mongoid-7.5.1 lib/mongoid/validatable/queryable.rb
mongoid-7.4.3 lib/mongoid/validatable/queryable.rb