mongocore 0.5.0 → 0.5.1
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/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/mongocore.rb +1 -1
- data/lib/mongocore/document.rb +14 -19
- data/mongocore.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 382b9b3968b584597a457ebed2f365730557c323
|
4
|
+
data.tar.gz: 492b741b39125f546f247d62b79a06f3f4493d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 757125a2055f3256ca6d75458f7bcc8af65444ab547f14c0bfbe88a95366b1bf47f5798eae9bfd65ca5fa6b4cfc5a82360a42c9e7be28f248a6ddf3f626d7acc
|
7
|
+
data.tar.gz: 789f922a38f52ce49d28e329c7fddd98b813696b7323bc65395ec15a8f27f567a882a670c2631fb6c787a500e0c9c381bb15dfb0d38754a96e64708ba0977eb4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,13 +15,13 @@ With Mongocore you can do:
|
|
15
15
|
|
16
16
|
The schema is specified with a YAML file which supports default values, data types, and security levels for each key.
|
17
17
|
|
18
|
-
Please read [the source code](https://github.com/fugroup/mongocore/tree/master/lib/mongocore) to see how it works, it's fully commented and very small, only 8 files, and
|
18
|
+
Please read [the source code](https://github.com/fugroup/mongocore/tree/master/lib/mongocore) to see how it works, it's fully commented and very small, only 8 files, and 519 lines of fully test driven code.
|
19
19
|
|
20
20
|
| Library | Files | Comment | Lines of code |
|
21
21
|
| -------------------------------------- | ----- | ------- | ------------- |
|
22
22
|
| [Mongoid](http://mongoid.com) | 256 | 14371 | 10590 |
|
23
23
|
| [MongoMapper](http://mongomapper.com) | 91 | 200 | 4070 |
|
24
|
-
| [Mongocore](http://mongocore.com) | 8 |
|
24
|
+
| [Mongocore](http://mongocore.com) | 8 | 275 | 519 |
|
25
25
|
|
26
26
|
<br>
|
27
27
|
|
data/lib/mongocore.rb
CHANGED
data/lib/mongocore/document.rb
CHANGED
@@ -41,7 +41,7 @@ module Mongocore
|
|
41
41
|
# @persisted indicates whether this is saved or not
|
42
42
|
#
|
43
43
|
|
44
|
-
attr_accessor :errors, :changes, :persisted
|
44
|
+
attr_accessor :errors, :changes, :persisted
|
45
45
|
|
46
46
|
# # # # # # # # # # #
|
47
47
|
# The class initializer, called when you write Model.new
|
@@ -50,9 +50,6 @@ module Mongocore
|
|
50
50
|
#
|
51
51
|
def initialize(a = {})
|
52
52
|
|
53
|
-
# Storing original state for dirty tracking
|
54
|
-
@original = {}
|
55
|
-
|
56
53
|
# Store attributes.
|
57
54
|
self.attributes = @_id ? a : self.class.schema.defaults.merge(a)
|
58
55
|
|
@@ -105,7 +102,7 @@ module Mongocore
|
|
105
102
|
|
106
103
|
# Reset internals
|
107
104
|
def reset!
|
108
|
-
@
|
105
|
+
@changes.clear; @errors.clear
|
109
106
|
end
|
110
107
|
|
111
108
|
|
@@ -189,10 +186,8 @@ module Mongocore
|
|
189
186
|
|
190
187
|
if @changes
|
191
188
|
# Record change for dirty attributes
|
192
|
-
@changes
|
193
|
-
|
194
|
-
# Store original values for dirty tracking support
|
195
|
-
@original[key] = v
|
189
|
+
r = @changes.has_key?(key) ? @changes[key][0] : read!(key)
|
190
|
+
@changes[key] = [r, v] if r != v
|
196
191
|
end
|
197
192
|
|
198
193
|
# Write attribute
|
@@ -206,17 +201,17 @@ module Mongocore
|
|
206
201
|
|
207
202
|
# Write or read
|
208
203
|
if self.class.schema.keys.has_key?(key = $1.to_sym)
|
209
|
-
|
204
|
+
$2 ? write(key, args.first) : read(key)
|
205
|
+
elsif key =~ /(.+)_changed\?/
|
206
|
+
# Attributes changed?
|
207
|
+
@changes.has_key?($1.to_sym)
|
208
|
+
elsif key =~ /(.+)_was/
|
209
|
+
# Attributes was
|
210
|
+
@changes.empty? ? read($1) : @changes[$1.to_sym][0]
|
211
|
+
else
|
212
|
+
# Pass if nothing found
|
213
|
+
super
|
210
214
|
end
|
211
|
-
|
212
|
-
# Attributes changed?
|
213
|
-
return @changes.has_key?($1.to_sym) if key =~ /(.+)_changed\?/
|
214
|
-
|
215
|
-
# Attributes was
|
216
|
-
return @original[$1.to_sym] if key =~ /(.+)_was/
|
217
|
-
|
218
|
-
# Pass if nothing found
|
219
|
-
super
|
220
215
|
end
|
221
216
|
|
222
217
|
# Alias for _id but returns string
|
data/mongocore.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mongocore'
|
3
|
-
s.version = '0.5.
|
3
|
+
s.version = '0.5.1'
|
4
4
|
s.date = '2018-01-24'
|
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."
|