validate 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+
2
+
3
+ require 'kongo'
4
+
5
+ # This file bridges Kongo and Validate by adding support for a validates?
6
+ # method to Kongo::Collection.
7
+ #
8
+ module Kongo
9
+
10
+ class Collection
11
+
12
+ # Returns whether `hash` would be a valid model if inserted.
13
+ #
14
+ def validates?(hash)
15
+ hash = hash.dup
16
+ hash['_id'] = BSON::ObjectId.new unless hash.include?('_id')
17
+ model = ::Kongo::Model.new(hash, coll)
18
+ # NOTE: raises NoMethodError if the model does not have validations
19
+ model.validates?
20
+ end
21
+ end
22
+ end
23
+
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Validate
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
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.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,6 +40,7 @@ files:
40
40
  - README.md
41
41
  - Rakefile
42
42
  - lib/validate.rb
43
+ - lib/validate/kongo.rb
43
44
  - lib/validate/parser.rb
44
45
  - lib/validate/validations.rb
45
46
  - lib/validate/validator.rb