mongo_doc 0.6.15 → 0.6.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/lib/mongo_doc/attributes.rb +8 -2
- data/lib/mongo_doc.rb +1 -1
- data/mongo_doc.gemspec +2 -2
- data/spec/attributes_spec.rb +14 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.16
|
data/lib/mongo_doc/attributes.rb
CHANGED
@@ -48,7 +48,7 @@ module MongoDoc
|
|
48
48
|
_keys << name unless _keys.include?(name)
|
49
49
|
attr_writer name
|
50
50
|
|
51
|
-
|
51
|
+
unless default.nil?
|
52
52
|
define_method("_default_#{name}", default.kind_of?(Proc) ? default : proc { default })
|
53
53
|
private "_default_#{name}"
|
54
54
|
|
@@ -65,7 +65,13 @@ module MongoDoc
|
|
65
65
|
attr_reader name
|
66
66
|
end
|
67
67
|
|
68
|
-
if type
|
68
|
+
if type == Boolean
|
69
|
+
module_eval(<<-RUBY, __FILE__, __LINE__)
|
70
|
+
alias #{name}? #{name} # alias active? active
|
71
|
+
RUBY
|
72
|
+
end
|
73
|
+
|
74
|
+
if type.try(:respond_to?, :cast_from_string)
|
69
75
|
define_method "#{name}_with_type=" do |value|
|
70
76
|
if value.kind_of?(String)
|
71
77
|
value = type.cast_from_string(value)
|
data/lib/mongo_doc.rb
CHANGED
data/mongo_doc.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongo_doc}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Les Hill"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-10}
|
13
13
|
s.description = %q{ODM for MongoDB}
|
14
14
|
s.email = %q{leshill@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/attributes_spec.rb
CHANGED
@@ -28,6 +28,7 @@ describe "MongoDoc::Attributes" do
|
|
28
28
|
|
29
29
|
attr_accessor :attr1, :attr2
|
30
30
|
attr_accessor :validation_context
|
31
|
+
attr_accessor :boolean, :type => Boolean
|
31
32
|
end
|
32
33
|
|
33
34
|
it "adds its arguments to _keys" do
|
@@ -58,6 +59,14 @@ describe "MongoDoc::Attributes" do
|
|
58
59
|
it "has an attr1 writer" do
|
59
60
|
should respond_to(:attr1=)
|
60
61
|
end
|
62
|
+
|
63
|
+
it "has a reader for a boolean" do
|
64
|
+
should respond_to(:boolean)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "has a ? reader for a boolean" do
|
68
|
+
should respond_to(:boolean?)
|
69
|
+
end
|
61
70
|
end
|
62
71
|
|
63
72
|
context "default values" do
|
@@ -65,6 +74,7 @@ describe "MongoDoc::Attributes" do
|
|
65
74
|
include MongoDoc::Attributes
|
66
75
|
|
67
76
|
attr_accessor :with_default, :default => 'value'
|
77
|
+
attr_accessor :boolean_default, :type => Boolean, :default => false
|
68
78
|
end
|
69
79
|
|
70
80
|
let(:object) { TestDefault.new }
|
@@ -87,6 +97,10 @@ describe "MongoDoc::Attributes" do
|
|
87
97
|
object.with_default = nil
|
88
98
|
object.with_default.should be_nil
|
89
99
|
end
|
100
|
+
|
101
|
+
it "allows a false default for booleans" do
|
102
|
+
object.boolean_default.should == false
|
103
|
+
end
|
90
104
|
end
|
91
105
|
|
92
106
|
context "specified type" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 16
|
10
|
+
version: 0.6.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Les Hill
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-10 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|