validate 1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/validate/kongo.rb +17 -6
- data/lib/validate/version.rb +1 -1
- metadata +2 -2
data/lib/validate/kongo.rb
CHANGED
@@ -34,16 +34,27 @@ module Kongo
|
|
34
34
|
# extensions, which are implemented differently from regular extensions.
|
35
35
|
#
|
36
36
|
def self.add_validation_extension(collection_name, mod)
|
37
|
-
@@validations = mod.validations
|
38
|
-
((@@extensions ||= {})[collection_name.to_sym] ||= []) << mod
|
37
|
+
(@@validations ||= {})[collection_name.to_sym] = mod.validations
|
39
38
|
end
|
40
39
|
|
41
|
-
#
|
42
|
-
# to run. Do not call this directly.
|
40
|
+
# Override initialize to also set @validator.
|
43
41
|
#
|
44
|
-
|
45
|
-
|
42
|
+
alias :original_initialize :initialize
|
43
|
+
def initialize(*args)
|
44
|
+
ret = original_initialize(*args)
|
45
|
+
@validator = (@@validations ||= {})[@coll.name.to_sym]
|
46
|
+
ret
|
46
47
|
end
|
48
|
+
|
49
|
+
# Implements interface to validations via the two usual methods.
|
50
|
+
#
|
51
|
+
def validates?
|
52
|
+
@validator.validates?(self)
|
53
|
+
end
|
54
|
+
def failures
|
55
|
+
@validator.failures
|
56
|
+
end
|
57
|
+
|
47
58
|
end
|
48
59
|
end
|
49
60
|
|
data/lib/validate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|