Sha256: 084b9434c07a9a43314d9c2124cdab5750cd68cbadca8a9ba960f8efcadb4b3f
Contents?: true
Size: 838 Bytes
Versions: 4
Compression:
Stored size: 838 Bytes
Contents
# encoding: utf-8 module Mongoid module Validations 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("#{klass.name}-validate-with-query") yield ensure klass.clear_persistence_options unless document.errors.empty? Threaded.exit("#{klass.name}-validate-with-query") end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems