uorm 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/uorm/dsl.rb +3 -3
- data/lib/uorm/mongo.rb +0 -25
- data/lib/uorm/mongo/persistance.rb +4 -3
- data/lib/uorm/redis.rb +0 -14
- data/lib/uorm/version.rb +1 -1
- metadata +1 -1
data/lib/uorm/dsl.rb
CHANGED
@@ -33,18 +33,18 @@ module Uorm
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def save &block
|
36
|
-
new? ?
|
36
|
+
new? ? persistance.create(self, &block) : persistance.update(self, &block)
|
37
37
|
self
|
38
38
|
end
|
39
39
|
|
40
40
|
def update attrs
|
41
41
|
update_attributes attrs
|
42
|
-
|
42
|
+
persistance.update self
|
43
43
|
self
|
44
44
|
end
|
45
45
|
|
46
46
|
def delete
|
47
|
-
|
47
|
+
persistance.delete self
|
48
48
|
self
|
49
49
|
end
|
50
50
|
end
|
data/lib/uorm/mongo.rb
CHANGED
@@ -23,31 +23,6 @@ module Uorm
|
|
23
23
|
def persistance
|
24
24
|
self.class.persistance
|
25
25
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def perform_create &block
|
30
|
-
fiber = Fiber.current
|
31
|
-
create_callback = Callbacks::Create.new
|
32
|
-
create_callback.callback &block
|
33
|
-
resp = persistance.create(self)
|
34
|
-
resp.callback { |object_id| fiber.resume object_id }
|
35
|
-
resp.errback { |err, msg| raise err.new msg }
|
36
|
-
self.id = Fiber.yield
|
37
|
-
create_callback.succeed self
|
38
|
-
end
|
39
|
-
|
40
|
-
def perform_update &block
|
41
|
-
update_callback = Callbacks::Update.new
|
42
|
-
update_callback.callback &block
|
43
|
-
persistance.update self do
|
44
|
-
update_callback.succeed self
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def perform_delete
|
49
|
-
persistance.delete self
|
50
|
-
end
|
51
26
|
end
|
52
27
|
end
|
53
28
|
end
|
@@ -31,12 +31,13 @@ module Uorm
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def create object
|
35
|
-
collection.safe_insert(object.attributes.except(:id))
|
34
|
+
def create object, &block
|
35
|
+
object.id = EM::Synchrony.sync collection.safe_insert(object.attributes.except(:id))
|
36
|
+
yield object if block_given?
|
36
37
|
end
|
37
38
|
|
38
39
|
def update object
|
39
|
-
collection.safe_update({_id: object.id}, object.attributes.except(:id))
|
40
|
+
EventMachine::Synchrony.sync collection.safe_update({_id: object.id}, object.attributes.except(:id))
|
40
41
|
end
|
41
42
|
|
42
43
|
def delete object
|
data/lib/uorm/redis.rb
CHANGED
@@ -21,20 +21,6 @@ module Uorm
|
|
21
21
|
def persistance
|
22
22
|
self.class.persistance
|
23
23
|
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def perform_create
|
28
|
-
persistance.create self
|
29
|
-
end
|
30
|
-
|
31
|
-
def perform_update
|
32
|
-
persistance.update self
|
33
|
-
end
|
34
|
-
|
35
|
-
def perform_delete
|
36
|
-
persistance.delete self
|
37
|
-
end
|
38
24
|
end
|
39
25
|
end
|
40
26
|
end
|
data/lib/uorm/version.rb
CHANGED