Sha256: 8edc4869364dc4b7cb7676109b149749e940a58d2aa95465f379e156aa9eb22c

Contents?: true

Size: 786 Bytes

Versions: 14

Compression:

Stored size: 786 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Validatable
    module Queryable

      # Wrap the validation inside the an execution block that alert's the
      # session 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.
      #
      # @since 3.0.2
      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

14 entries across 14 versions & 5 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/lib/mongoid/validatable/queryable.rb
mongoid-4.0.2 lib/mongoid/validatable/queryable.rb
mongoid-4.0.1 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.rc2 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.rc1 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.beta2 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.beta1 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.alpha2 lib/mongoid/validatable/queryable.rb
mongoid-4.0.0.alpha1 lib/mongoid/validatable/queryable.rb
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/validatable/queryable.rb
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/validatable/queryable.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/validatable/queryable.rb
mongoid_rails4-4.0.0 lib/mongoid/validatable/queryable.rb