minidoc 1.0.0 → 1.0.1

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: 6a93bcb6c9ec2ce2f698542c38ee475a3a246c65
4
- data.tar.gz: 6b079b09ae01f3d2872669026ff0f3030265ea15
3
+ metadata.gz: a39428fa02e34cc7687e65ebc52bda5a0dfa5417
4
+ data.tar.gz: 4bb38f83b40229e7709bb57689388cf8601671fa
5
5
  SHA512:
6
- metadata.gz: 2dc2ef8cd682a5d54ded8bc8777f2c886edce48c22770ae61bc598672be1d45c7e2eae1e7d8d1c03340e169246b46583b95e529368bbfc55bd5ad43a336770d5
7
- data.tar.gz: 188a9383eeeb2b80df81900ac8cddb84247b9b442db439a0890c438543f267dd35305abea33ecdc362253d948fdc931bd65da365d410e4bf6768d98bd816130f
6
+ metadata.gz: 3e03054151882676cae311c7967eac76b82461c7cf51eff00edac9edfec77ea8f61f7bb4476825d104150c7d44c5235e80aab8b9b626c3d9353fbf53300c1f12
7
+ data.tar.gz: ad3cf4397561d99fd462a2a42dbfe3a167a9b197566073480f8204b719bb349cb156bdd7ab11895929c7b8e77e69f17fa9966a6c7a766f78e23a803dcb8bcfdc
data/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  ### Changes
10
10
 
11
+ ## v1.0.1 (2016-10-31)
12
+
13
+ ### Bug fixes
14
+
15
+ * Updated `updated_at` when enabled from all setter methods. ([@wfleming][])
16
+
11
17
  ## v1.0.0 (2016-10-27)
12
18
 
13
19
  No changes! Same as v1.0.0.rc2
data/README.md CHANGED
@@ -15,8 +15,8 @@ things as simple as possible.
15
15
 
16
16
  * Interact with Ruby objects instead of hashes
17
17
  * Full access to the powerful MongoDB client
18
- * Thread safe. (Hopefully)
19
- * Simple and easily extensible (Less than 500 lines of code.)
18
+ * Thread safe (hopefully)
19
+ * Simple and easily extensible
20
20
  * ActiveModel-compatible
21
21
  * Validations
22
22
  * Timestamp tracking (created_at/updated_at)
@@ -15,6 +15,28 @@ module Minidoc::Timestamps
15
15
  end
16
16
  end
17
17
 
18
+ def set(attributes)
19
+ if self.class.record_timestamps
20
+ super(attributes.merge(updated_at: Time.now.utc))
21
+ else
22
+ super(attributes)
23
+ end
24
+ end
25
+
26
+ def atomic_set(query, attributes)
27
+ if self.class.record_timestamps
28
+ super(query, attributes.merge(updated_at: Time.now.utc))
29
+ else
30
+ super(query, attributes)
31
+ end
32
+ end
33
+
34
+ def unset(*keys)
35
+ super
36
+
37
+ set(updated_at: Time.now.utc) if self.class.record_timestamps
38
+ end
39
+
18
40
  private
19
41
 
20
42
  def create
@@ -1,3 +1,3 @@
1
1
  class Minidoc
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -4,6 +4,8 @@ describe Minidoc::Timestamps do
4
4
  class TimestampsUser < Minidoc
5
5
  include Minidoc::Timestamps
6
6
 
7
+ attribute :name, String
8
+
7
9
  timestamps!
8
10
  end
9
11
 
@@ -20,5 +22,27 @@ describe Minidoc::Timestamps do
20
22
  user.save
21
23
  expect(user.created_at).to_not eq user.updated_at
22
24
  end
25
+
26
+ it "updates updated_at when doc is changed with #set" do
27
+ user = TimestampsUser.create
28
+ sleep 0.001
29
+ user.set(name: "Abby Normal")
30
+ expect(user.created_at).to_not eq user.updated_at
31
+ end
32
+
33
+ it "updates updated_at when doc is changed with #atomic_set" do
34
+ user = TimestampsUser.create
35
+ sleep 0.001
36
+ user.atomic_set({ name: nil }, name: "Abby Normal")
37
+ expect(user.created_at).to_not eq user.updated_at
38
+ end
39
+
40
+ it "updates updated_at when doc is changed with #unset" do
41
+ user = TimestampsUser.create(name: "Abby Normal")
42
+ sleep 0.001
43
+ user.unset(:name)
44
+ expect(user.name).to be_nil
45
+ expect(user.created_at).to_not eq user.updated_at
46
+ end
23
47
  end
24
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-28 00:00:00.000000000 Z
12
+ date: 2016-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport