serialize_virtual_attributes 0.0.4 → 0.0.5

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: 763443618dc09ec047b4a68d4dd39c867b64fc50
4
- data.tar.gz: 51ccfe0e8dde1091e2db36f818ba81d02a2226a0
3
+ metadata.gz: 57f1917e2e28c4fe3f86fa1e80448bf3645e72ce
4
+ data.tar.gz: 527a67f8923a2619b71a110afb65b56bb51eac66
5
5
  SHA512:
6
- metadata.gz: 43f19202bc0033b9785fb79dcf1906a93505698305917abfd4116eacbad34a5cce7089eb84d309451ddfadf429d00990271546396b6506a8a12abf4edb820d2f
7
- data.tar.gz: 01bd19c0a77de64b0d89c938736baa5649605fc211b404578a7725b9c5b9581e448feab626927dc56371184d082f270915149faf43df3563918bf9217a8aaa0d
6
+ metadata.gz: 5fad6d78960642d426c405f603d71022ce44b5f26026bcca1b86fda142488b133ceec34b796f008866dc02df268b1a1fab609b36a150b0dbd1d6a84532c81066
7
+ data.tar.gz: 2175700a73941f9cbc5a789a56937dddd23221fbacce1990ccf04a877211034044b21a36efd705daede81ea4b590ac6d07762087df3c41f89a8464ce30e27270
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serialize_virtual_attributes (0.0.2)
4
+ serialize_virtual_attributes (0.0.4)
5
5
  activerecord (~> 3.1)
6
6
  activesupport (~> 3.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (3.2.18)
12
- activesupport (= 3.2.18)
11
+ activemodel (3.2.19)
12
+ activesupport (= 3.2.19)
13
13
  builder (~> 3.0.0)
14
- activerecord (3.2.18)
15
- activemodel (= 3.2.18)
16
- activesupport (= 3.2.18)
14
+ activerecord (3.2.19)
15
+ activemodel (= 3.2.19)
16
+ activesupport (= 3.2.19)
17
17
  arel (~> 3.0.2)
18
18
  tzinfo (~> 0.3.29)
19
- activesupport (3.2.18)
19
+ activesupport (3.2.19)
20
20
  i18n (~> 0.6, >= 0.6.4)
21
21
  multi_json (~> 1.0)
22
22
  arel (3.0.3)
@@ -41,7 +41,7 @@ GEM
41
41
  guard-rspec (4.2.9)
42
42
  guard (~> 2.1)
43
43
  rspec (>= 2.14, < 4.0)
44
- i18n (0.6.9)
44
+ i18n (0.6.11)
45
45
  listen (2.7.6)
46
46
  celluloid (>= 0.15.2)
47
47
  rb-fsevent (>= 0.9.3)
@@ -74,7 +74,7 @@ GEM
74
74
  terminal-notifier-guard (1.5.3)
75
75
  thor (0.19.1)
76
76
  timers (1.1.0)
77
- tzinfo (0.3.39)
77
+ tzinfo (0.3.41)
78
78
 
79
79
  PLATFORMS
80
80
  ruby
@@ -1,3 +1,3 @@
1
1
  module SerializeVirtualAttributes
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -32,7 +32,13 @@ module SerializeVirtualAttributes
32
32
  end
33
33
 
34
34
  define_method "#{attr}=" do |val|
35
+ original_val = self.public_send(to).send('[]', attr)
36
+
35
37
  self.public_send(to).send('[]=', attr, val)
38
+
39
+ if !self.new_record? && original_val != val
40
+ self.send("#{to}_will_change!")
41
+ end
36
42
  end
37
43
 
38
44
  define_method attr do
@@ -87,6 +87,10 @@ describe SerializeVirtualAttributes do
87
87
  end
88
88
 
89
89
  person = Person.create(first_name: "hao", last_name: "liu")
90
+
91
+ # 2 attributes changed, will receive this two times
92
+ expect(person).to receive(:fullname_will_change!).exactly(2).times
93
+
90
94
  person.update_attributes(first_name: "john", last_name: "doe")
91
95
  person.reload
92
96
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialize_virtual_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hao Liu