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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74fdbe4ae3a48d20051b091780897353f615973e
4
- data.tar.gz: b608caf9da396253e7024d84dfdff74547f01058
3
+ metadata.gz: 382b9b3968b584597a457ebed2f365730557c323
4
+ data.tar.gz: 492b741b39125f546f247d62b79a06f3f4493d6f
5
5
  SHA512:
6
- metadata.gz: d42222537d1c66933894c3c527742e690db6dc6acfe82e72e2394ce9192624c66d1f0c39ba2503f573fcab92e32dcd78790a88f3bd26f179aa94820ec5e18f52
7
- data.tar.gz: '0287ca2b41a01ca0b2ff079d5e457212690b3c5cb011ce3f4d4078a833b402b1bbebc5350e4da506d9f606c1025ec30cee610c3f5e0b1a2708f4d7aaab334157'
6
+ metadata.gz: 757125a2055f3256ca6d75458f7bcc8af65444ab547f14c0bfbe88a95366b1bf47f5798eae9bfd65ca5fa6b4cfc5a82360a42c9e7be28f248a6ddf3f626d7acc
7
+ data.tar.gz: 789f922a38f52ce49d28e329c7fddd98b813696b7323bc65395ec15a8f27f567a882a670c2631fb6c787a500e0c9c381bb15dfb0d38754a96e64708ba0977eb4
@@ -1,3 +1,8 @@
1
+ **Version 0.5.1** - *2018-01-24*
2
+
3
+ - Fixed and refactored dirty tracking
4
+
5
+
1
6
  **Version 0.5.0** - *2018-01-24*
2
7
 
3
8
  - Speed optimizations
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 450 lines of fully test driven code.
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 | 269 | 483 |
24
+ | [Mongocore](http://mongocore.com) | 8 | 275 | 519 |
25
25
 
26
26
  <br>
27
27
 
@@ -7,7 +7,7 @@ require 'mongo'
7
7
  require 'request_store'
8
8
 
9
9
  module Mongocore
10
- VERSION = '0.5.0'
10
+ VERSION = '0.5.1'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
@@ -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, :original
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
- @original = self.attributes; @changes.clear; @errors.clear
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[key] = [@original[key], v] if v != read!(key)
193
- else
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
- return $2 ? write(key, args.first) : read(key)
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongocore'
3
- s.version = '0.5.0'
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."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongocore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited