5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/validation_hints/validations_patch.rb', line 5
def self.apply!
return if applied?
ActiveModel::Validations::ClassMethods.module_eval do
def has_validations?
!validators.empty?
end
def has_validations_for?(attribute)
!validators_on(attribute).empty?
end
end
ActiveModel::Validations.module_eval do
def has_validations?
self.class.has_validations?
end
def has_validations_for?(attribute)
self.class.has_validations_for?(attribute)
end
def hints
@hints ||= ActiveModel::Hints.new(self)
end
end
@applied = true
end
|