attr_vault 0.1.1 → 0.1.2

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: 357be9f5ce89b5473ebde27f6b12821149b72c69
4
- data.tar.gz: 548d448526fb2c375bd77d88876c2b1317df45b2
3
+ metadata.gz: 86139c030cc0889d40ee3b40db69fe0b8b66beee
4
+ data.tar.gz: cadcf1eabcf1dc445edc9d8d423f66ff6cb58242
5
5
  SHA512:
6
- metadata.gz: 1cf7d0c6455857d0c15b7aff5bff86884223e660708767faae36ccadb0d06cf098845123609cb65f9e71baf008542fdb4d50b1b2efc459efc9491a97ebfa7d0e
7
- data.tar.gz: f3108dfbe9dd22231243a971f12c5162d785e959a26f668a6b904e32a5ea856fa1e87afc600a408efccc5dd9d978270cc22ab07fced09631547c72999740cfd9
6
+ metadata.gz: 4758d09746a415b03c7b2e187419501f78a3815b67a918e810c35b7cf6d90319f9fdcf32ce100bf8b48b25453a5831c11b8d98c446c80caef47b6cd5d9d07a14
7
+ data.tar.gz: bfca3f4fc0f177d8e4244e6e778b7f4d3a4599b9aab9a0f68e225e8ba4bfd22388938d75869a49ef31cc724160340aafb563c8309b2018976c723f094515bc7d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- attr_vault (0.1.1)
4
+ attr_vault (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AttrVault
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/attr_vault.rb CHANGED
@@ -102,6 +102,9 @@ module AttrVault
102
102
  end
103
103
 
104
104
  define_method("#{name}=") do |value|
105
+ old_value = self.public_send(name)
106
+ return if value == old_value
107
+
105
108
  @vault_dirty_attrs ||= {}
106
109
  @vault_dirty_attrs[name] = value
107
110
  # ensure that Sequel knows that this is in fact dirty and must
@@ -61,6 +61,14 @@ describe AttrVault do
61
61
  expect(s.secret_encrypted).not_to be_nil
62
62
  end
63
63
 
64
+ it "avoids updating existing values when those do not change" do
65
+ the_secret = "I'm not saying it was aliens..."
66
+ s = item.create(secret: the_secret)
67
+ s.reload
68
+ s.secret = the_secret
69
+ expect(s.save_changes).to be_nil
70
+ end
71
+
64
72
  it "stores the key id" do
65
73
  secret = 'it was professor plum with the wrench in the library'
66
74
  s = item.create(secret: secret)
@@ -119,6 +127,14 @@ describe AttrVault do
119
127
  expect(s.secret).to be_nil
120
128
  end
121
129
 
130
+ it "avoids updating existing values when those do not change" do
131
+ the_secret = "Satoshi Nakamoto"
132
+ s = item.create
133
+ s.update(secret: the_secret)
134
+ s.secret = the_secret
135
+ expect(s.save_changes).to be_nil
136
+ end
137
+
122
138
  it "reads the correct value for a dirty field before the object is saved" do
123
139
  s = item.create
124
140
  secret = 'mcmurphy is lobotomized =('
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciek Sakrejda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec