mongomatic 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongomatic/base.rb +12 -10
- data/test/helper.rb +3 -0
- data/test/test_mongomatic.rb +7 -0
- metadata +3 -3
data/lib/mongomatic/base.rb
CHANGED
@@ -69,14 +69,14 @@ module Mongomatic
|
|
69
69
|
do_callback(:after_drop)
|
70
70
|
end
|
71
71
|
|
72
|
+
[:before_drop, :after_drop].each do |method|
|
73
|
+
define_method(method) { true }
|
74
|
+
end
|
75
|
+
|
72
76
|
private
|
73
77
|
|
74
78
|
def do_callback(meth)
|
75
|
-
|
76
|
-
send(meth)
|
77
|
-
rescue NoMethodError => e
|
78
|
-
false
|
79
|
-
end
|
79
|
+
send(meth)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -238,6 +238,12 @@ module Mongomatic
|
|
238
238
|
@doc || {}
|
239
239
|
end
|
240
240
|
|
241
|
+
[ :before_validate, :after_validate, :before_insert, :before_insert_or_update,
|
242
|
+
:after_insert, :after_insert_or_update, :before_update, :after_update,
|
243
|
+
:before_remove, :after_remove].each do |method|
|
244
|
+
define_method(method) { true }
|
245
|
+
end
|
246
|
+
|
241
247
|
protected
|
242
248
|
|
243
249
|
def hash_for_field(field, break_if_dne=false)
|
@@ -254,11 +260,7 @@ module Mongomatic
|
|
254
260
|
end
|
255
261
|
|
256
262
|
def do_callback(meth)
|
257
|
-
|
258
|
-
send(meth)
|
259
|
-
rescue NoMethodError => e
|
260
|
-
false
|
261
|
-
end
|
263
|
+
send(meth)
|
262
264
|
end
|
263
265
|
end
|
264
266
|
end
|
data/test/helper.rb
CHANGED
data/test/test_mongomatic.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestMongomatic < Test::Unit::TestCase
|
4
|
+
should "not fail if callbacks are undefined" do
|
5
|
+
Car.collection.drop
|
6
|
+
c1 = Car.new(:make => "Honda", :model => "Accord")
|
7
|
+
c1.insert!
|
8
|
+
assert_equal c1, Car.find_one(c1["_id"])
|
9
|
+
end
|
10
|
+
|
4
11
|
should "treat all keys as strings" do
|
5
12
|
Person.collection.drop
|
6
13
|
p1 = Person.new(:name => "Jordan")
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 6
|
9
|
+
version: 0.5.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Myles
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-17 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|