mongoa 0.1.1 → 0.1.2
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/VERSION +1 -1
- data/lib/mongoa/mongo_mapper/association_matcher.rb +1 -1
- data/lib/mongoa/mongo_mapper/validations.rb +47 -0
- data/lib/mongoa.rb +1 -5
- data/mongoa.gemspec +3 -2
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Mongoa
|
2
|
+
module MongoMapper
|
3
|
+
module Matchers
|
4
|
+
|
5
|
+
def validate_presence_of(attr)
|
6
|
+
ValidatePresenceOfMatcher.new(attr)
|
7
|
+
end
|
8
|
+
|
9
|
+
class ValidatePresenceOfMatcher < ValidationMatcher
|
10
|
+
|
11
|
+
def with_message(message)
|
12
|
+
@expected_message = message if message
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches?(subject)
|
17
|
+
super(subject)
|
18
|
+
@expected_message ||= :blank
|
19
|
+
disallows_value_of(blank_value, @expected_message)
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
"require #{@attribute} to be set"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def blank_value
|
29
|
+
if collection?
|
30
|
+
[]
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def collection?
|
37
|
+
if reflection = @subject.class.reflect_on_association(@attribute)
|
38
|
+
[:has_many, :has_and_belongs_to_many].include?(reflection.macro)
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/mongoa.rb
CHANGED
data/mongoa.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoa}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott J. Tamosunas"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-09}
|
13
13
|
s.description = %q{Adds the association and validation macros for Rspec in the same way Shoulda does for ActiveRecord.}
|
14
14
|
s.email = %q{tamosunas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/mongoa/mongo_mapper/association_matcher.rb",
|
29
29
|
"lib/mongoa/mongo_mapper/associations.rb",
|
30
30
|
"lib/mongoa/mongo_mapper/matchers.rb",
|
31
|
+
"lib/mongoa/mongo_mapper/validations.rb",
|
31
32
|
"mongoa.gemspec",
|
32
33
|
"spec/mongoa_spec.rb",
|
33
34
|
"spec/spec.opts",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott J. Tamosunas
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-09 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/mongoa/mongo_mapper/association_matcher.rb
|
54
54
|
- lib/mongoa/mongo_mapper/associations.rb
|
55
55
|
- lib/mongoa/mongo_mapper/matchers.rb
|
56
|
+
- lib/mongoa/mongo_mapper/validations.rb
|
56
57
|
- mongoa.gemspec
|
57
58
|
- spec/mongoa_spec.rb
|
58
59
|
- spec/spec.opts
|