Sha256: e599045ea8c5b0865f3b91d3815474e890b90cbf4cbf18fd78d0d5a149dc5375
Contents?: true
Size: 807 Bytes
Versions: 11
Compression:
Stored size: 807 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) 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
11 entries across 11 versions & 2 rubygems