aboutsummaryrefslogtreecommitdiff
path: root/lib/dm-validations-with-empty-errors-hack.rb
blob: 827f1d0c597f54f9a9ce0f8959a038d521091987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'dm-validations'

module DataMapper
  module Validations
    #
    # This only performs validations if the object being saved is dirty.
    #
    def save_self(*)
      # 
      # short-circuit if the resource is not dirty
      #
      if dirty_self? && Validations::Context.any? && !valid?(model.validators.current_context)
        false
      else
        super
      end
    end
  end
end