validate 1.0.2 → 1.0.3
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 +19 -1
- data/lib/validate/version.rb +1 -1
- metadata +2 -2
data/lib/validate/kongo.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
require 'kongo'
|
4
|
+
require 'validate'
|
4
5
|
|
5
6
|
# This file bridges Kongo and Validate by adding support for a validates?
|
6
7
|
# method to Kongo::Collection.
|
@@ -15,9 +16,26 @@ module Kongo
|
|
15
16
|
hash = hash.dup
|
16
17
|
hash['_id'] = BSON::ObjectId.new unless hash.include?('_id')
|
17
18
|
model = ::Kongo::Model.new(hash, coll)
|
18
|
-
# NOTE: raises NoMethodError if the model does not have validations
|
19
19
|
model.validates?
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
class Model
|
24
|
+
|
25
|
+
# This is the same as add_extension, but should be used to add validation
|
26
|
+
# extensions, which are implemented differently from regular extensions.
|
27
|
+
#
|
28
|
+
def self.add_validation_extension(collection_name, mod)
|
29
|
+
@@validations = mod.validations
|
30
|
+
((@@extensions ||= {})[collection_name.to_sym] ||= []) << mod
|
31
|
+
end
|
32
|
+
|
33
|
+
# This method is used by the validations library to fetch the validations
|
34
|
+
# to run. Do not call this directly.
|
35
|
+
#
|
36
|
+
def self.validations
|
37
|
+
@@validations
|
38
|
+
end
|
39
|
+
end
|
22
40
|
end
|
23
41
|
|
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: 1.0.
|
4
|
+
version: 1.0.3
|
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-04-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|