mongocore 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 548f2d755136649ef451c214273f13e261db0a1d
4
- data.tar.gz: edc4767ca3415cd4381e529491514341c1a53dde
3
+ metadata.gz: 101270d2604389fccdfd5cb57406447a7a722ee6
4
+ data.tar.gz: 94e67537e7c525525bde6af3afeb63d1160d994d
5
5
  SHA512:
6
- metadata.gz: fd0305e629d7514df1c7d787670f5dd61a1969838c8eb130d5d59a77ec94e995fb98d085e9573d023505be3c54ddf08e431c4d7e01b8881777c4493c8c08dc36
7
- data.tar.gz: 81e4547ae938a84031a120fc481820cac6dfc97835e614b17db6d4231651c4e4d111d64a8d2c3b02e26e9bd11db86b34852df4f7e4833124f66313f9e088a975
6
+ metadata.gz: 213d43d5682528b73b2088fb5e65fdba442b8e78f768cb40875aa5778ed4d3cefbbe6e7ddad5b91319de6250255b6a051a443e54b0a7582f0a5e29763d9c4195
7
+ data.tar.gz: 5af984bb234f941208cbbba636ff6183bc07f1d3e9e30d41162078434a7798b60bf3026dd4d0d87685ef7d3d3d44bb4558c9958e600637989a0b7e6048e7f1e6
@@ -1,3 +1,7 @@
1
+ **Version 0.4.4** - *2018-01-19*
2
+
3
+ - Fixed dirty tracking clearing after save
4
+
1
5
  **Version 0.4.3** - *2018-01-19*
2
6
 
3
7
  - Reset model properly when doing a reload
@@ -7,7 +7,7 @@ require 'mongo'
7
7
  require 'request_store'
8
8
 
9
9
  module Mongocore
10
- VERSION = '0.4.3'
10
+ VERSION = '0.4.4'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
@@ -50,8 +50,11 @@ module Mongocore
50
50
  #
51
51
  def initialize(a = {})
52
52
 
53
- # Store attributes. Storing original state for dirty tracking.
54
- self.attributes = self.class.schema.defaults.merge(a).tap{|r| @original = r.dup}
53
+ # Store attributes.
54
+ self.attributes = @_id ? a : self.class.schema.defaults.merge(a)
55
+
56
+ # Storing original state for dirty tracking.
57
+ @original = self.attributes
55
58
 
56
59
  # The _id is a BSON object, create new unless it exists
57
60
  @_id ? @persisted = true : @_id = BSON::ObjectId.new
@@ -87,12 +90,12 @@ module Mongocore
87
90
 
88
91
  # Run filters before and after accessing the db
89
92
  def filter(cmd, persisted = true, &block)
90
- run(:before, cmd); yield.tap{@persisted = persisted; run(:after, cmd)}
93
+ run(:before, cmd); yield.tap{@persisted = persisted; run(:after, cmd); reset!}
91
94
  end
92
95
 
93
96
  # Reload the document from db and update attributes
94
97
  def reload
95
- one.first.tap{|m| self.attributes = m.attributes; @original = m.attributes.dup; @changes.clear; @errors.clear}
98
+ one.first.tap{|m| self.attributes = m.attributes; reset!}
96
99
  end
97
100
 
98
101
  # Set the timestamps if enabled
@@ -100,6 +103,11 @@ module Mongocore
100
103
  t = Time.now.utc; @updated_at = t; @created_at = t if unsaved?
101
104
  end
102
105
 
106
+ # Reset internals
107
+ def reset!
108
+ @original = self.attributes; @changes.clear; @errors.clear
109
+ end
110
+
103
111
 
104
112
  # # # # # # # # # # # # # # # #
105
113
  # Attribute methods
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongocore'
3
- s.version = '0.4.3'
3
+ s.version = '0.4.4'
4
4
  s.date = '2018-01-19'
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.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited