mongocore 0.1.5.6 → 0.1.6
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.
- checksums.yaml +4 -4
- data/lib/mongocore/document.rb +3 -3
- data/lib/mongocore/schema.rb +4 -2
- data/lib/mongocore.rb +1 -1
- data/mongocore.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2398fe451c3d58b40b9a635a4e5cd365a702cc3
|
4
|
+
data.tar.gz: 2e3f32a1f68b45543e75b5dfd9c607d7c81e682a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33843a29724bfcdb0e2e61a9ec9cf4bfae5df8990c1ab250c7bc1a0f8426e9997b53622476fbe553f7a397df3edd311038c13b6582e304358e952a87336a31c6
|
7
|
+
data.tar.gz: 6dfae14f09cf37cc1eafd82fd4920e37c676f3682f1ccf1f6fa9bc2b892c910c4a68a72426b9af13eba9ae383bef63ad52c569084a2e4865f72d5ddcf762ba9f
|
data/lib/mongocore/document.rb
CHANGED
@@ -92,7 +92,7 @@ module Mongocore
|
|
92
92
|
|
93
93
|
# Reload the document from db and update attributes
|
94
94
|
def reload
|
95
|
-
one.first.tap{|m| attributes = m.attributes}
|
95
|
+
one.first.tap{|m| self.attributes = m.attributes}
|
96
96
|
end
|
97
97
|
|
98
98
|
# Set the timestamps if enabled
|
@@ -107,7 +107,7 @@ module Mongocore
|
|
107
107
|
|
108
108
|
# Collect the attributes, pass tags like defined in your model yml
|
109
109
|
def attributes(*tags)
|
110
|
-
a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)};
|
110
|
+
a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)}; a
|
111
111
|
end
|
112
112
|
|
113
113
|
# Set the attributes
|
@@ -122,7 +122,7 @@ module Mongocore
|
|
122
122
|
|
123
123
|
# JSON format
|
124
124
|
def as_json(options = {})
|
125
|
-
attributes
|
125
|
+
string_id(attributes)
|
126
126
|
end
|
127
127
|
|
128
128
|
|
data/lib/mongocore/schema.rb
CHANGED
@@ -53,8 +53,10 @@ module Mongocore
|
|
53
53
|
elsif type == :integer then val.to_i
|
54
54
|
elsif type == :float then val.to_f
|
55
55
|
elsif type == :boolean then val.to_s.to_bool
|
56
|
-
elsif type == :object_id
|
57
|
-
BSON::ObjectId
|
56
|
+
elsif type == :object_id
|
57
|
+
# Convert string id to BSON::ObjectId
|
58
|
+
val.each{|k, v| val[k] = BSON::ObjectId.from_string(v) if v.is_a?(String)} if val.is_a?(Hash)
|
59
|
+
BSON::ObjectId.from_string(val) rescue val
|
58
60
|
else
|
59
61
|
val
|
60
62
|
end
|
data/lib/mongocore.rb
CHANGED
data/mongocore.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mongocore'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2017-10-
|
3
|
+
s.version = '0.1.6'
|
4
|
+
s.date = '2017-10-21'
|
5
5
|
s.summary = "MongoDB ORM implementation on top of the Ruby MongoDB driver"
|
6
6
|
s.description = "Does validations, associations, scopes, filters, pagination, counter cache, request cache, and nested queries. Using a YAML schema file, which supports default values, data types, and security levels for each key."
|
7
7
|
s.authors = ["Fugroup Limited"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongocore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|