uorm 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/uorm.rb +7 -9
- data/lib/uorm/dsl.rb +8 -0
- data/lib/uorm/{em-mongo.rb → mongo.rb} +3 -1
- data/lib/uorm/{em-mongo → mongo}/db.rb +1 -1
- data/lib/uorm/{em-mongo → mongo}/object_id.rb +0 -0
- data/lib/uorm/{em-mongo → mongo}/persistance.rb +5 -3
- data/lib/uorm/version.rb +1 -1
- data/spec/em-mongo_spec.rb +2 -2
- metadata +6 -6
data/lib/uorm.rb
CHANGED
@@ -3,6 +3,8 @@ require 'uorm/version'
|
|
3
3
|
require 'active_support/callbacks'
|
4
4
|
require 'active_support/core_ext/hash'
|
5
5
|
|
6
|
+
require 'em-synchrony'
|
7
|
+
|
6
8
|
module Uorm
|
7
9
|
autoload :Type, 'uorm/type'
|
8
10
|
autoload :Field, 'uorm/field'
|
@@ -15,17 +17,13 @@ module Uorm
|
|
15
17
|
module Redis
|
16
18
|
autoload :Persistance, 'uorm/redis/persistance'
|
17
19
|
autoload :DB, 'uorm/redis/db'
|
18
|
-
require 'multi_json'
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
autoload :Mongo, 'uorm/mongo'
|
23
|
+
module Mongo
|
24
|
+
require 'uorm/mongo/object_id'
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
autoload :DB, 'uorm/em-mongo/db'
|
27
|
-
autoload :Persistance, 'uorm/em-mongo/persistance'
|
28
|
-
end
|
26
|
+
autoload :DB, 'uorm/mongo/db'
|
27
|
+
autoload :Persistance, 'uorm/mongo/persistance'
|
29
28
|
end
|
30
|
-
|
31
29
|
end
|
data/lib/uorm/dsl.rb
CHANGED
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Uorm
|
2
|
-
module
|
2
|
+
module Mongo
|
3
3
|
class Persistance
|
4
4
|
attr_reader :collection, :model
|
5
5
|
|
@@ -33,11 +33,13 @@ module Uorm
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def create object
|
36
|
-
object.id = collection.
|
36
|
+
object.id = ::EM::Synchrony.sync collection.safe_insert(object.attributes.except(:id), safe: false)
|
37
|
+
rescue
|
38
|
+
false
|
37
39
|
end
|
38
40
|
|
39
41
|
def update object
|
40
|
-
collection.
|
42
|
+
::EM::Synchrony.sync collection.safe_update({_id: object.id}, object.attributes.except(:id), safe: false)
|
41
43
|
end
|
42
44
|
|
43
45
|
def delete object
|
data/lib/uorm/version.rb
CHANGED
data/spec/em-mongo_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require 'spec_helper'
|
|
3
3
|
require 'em-mongo'
|
4
4
|
require 'em-synchrony/em-mongo'
|
5
5
|
|
6
|
-
Uorm::
|
6
|
+
Uorm::Mongo::DB.name = 'uorm_test'
|
7
7
|
|
8
8
|
class AMongoModel
|
9
9
|
include Uorm::DSL
|
10
10
|
include Uorm::Attributes
|
11
|
-
include Uorm::
|
11
|
+
include Uorm::Mongo
|
12
12
|
|
13
13
|
field :reference, type: Uorm::Type::ObjectId
|
14
14
|
field :name, type: Uorm::Type::String
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -172,12 +172,12 @@ files:
|
|
172
172
|
- lib/uorm/attributes.rb
|
173
173
|
- lib/uorm/callbacks.rb
|
174
174
|
- lib/uorm/dsl.rb
|
175
|
-
- lib/uorm/em-mongo.rb
|
176
|
-
- lib/uorm/em-mongo/db.rb
|
177
|
-
- lib/uorm/em-mongo/object_id.rb
|
178
|
-
- lib/uorm/em-mongo/persistance.rb
|
179
175
|
- lib/uorm/field.rb
|
180
176
|
- lib/uorm/field_collection.rb
|
177
|
+
- lib/uorm/mongo.rb
|
178
|
+
- lib/uorm/mongo/db.rb
|
179
|
+
- lib/uorm/mongo/object_id.rb
|
180
|
+
- lib/uorm/mongo/persistance.rb
|
181
181
|
- lib/uorm/redis.rb
|
182
182
|
- lib/uorm/redis/db.rb
|
183
183
|
- lib/uorm/redis/persistance.rb
|