has_versions 0.8.0 → 0.9.0

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: 5c8b422b5420880774f2c762226fe857089fa499
4
- data.tar.gz: 879836886df8c06af5f1faa92718f3a22da8eaa3
3
+ metadata.gz: 27bbc91a2c9695f07af210889edbf3f443ba58ca
4
+ data.tar.gz: 82c7aba991d82e9505e4588995b0cf18345914df
5
5
  SHA512:
6
- metadata.gz: ec00d321511442b133f24249c4a1b303cb8ce1a70c2c3e27cc221c9e4e887b6e855cb9b16977f248b07c3b876ef70cab966987db81f80e734d9512c000d3328a
7
- data.tar.gz: 1388cfa1208f095bc8dc2684005c9323c785c28a37fca1c336811cf22a0b987a2f28022e78b3dc1b0dd2f0e5abd00c8ecfa254a79235b0b3002b67776c887b9c
6
+ metadata.gz: a451cb20e408f91b2caf65443bd25070f9f0476af8bfd2b09b010635b4d01b84d65fdc6fabf8c622117af3e6c8d823c6b782402d8d8c1fa25cbb47a20c98f582
7
+ data.tar.gz: 32bc445bed46d872fd160adc5672ea3d31e526bab1c394ed5f8602506cbfa9b257e0349c7923f302c05b5bf4c9ba35c3b203e535bf472dd401218a8772c1cdc6
data/has_versions.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "has_versions"
4
- s.version = '0.8.0'
4
+ s.version = '0.9.0'
5
5
 
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Grant Rodgers"]
@@ -30,17 +30,26 @@ module HasVersions
30
30
  @decoded_snapshot ||= begin
31
31
  decoded = {}
32
32
  target.class.versioned_attributes.each do |attribute|
33
- decoded[attribute] = target.versioning_decode_value(attribute, snapshot[attribute])
33
+ decoded[attribute] = decode_attribute(attribute, snapshot[attribute])
34
34
  end
35
35
  decoded
36
36
  end
37
37
  end
38
38
 
39
39
  private
40
+
41
+ def decode_attribute(attribute, value)
42
+ value = target.versioning_decode_value(attribute, snapshot[attribute])
43
+
44
+ @dummy_target ||= target.class.new
45
+ @dummy_target.send("#{attribute}=", value)
46
+ @dummy_target.send(attribute).presence
47
+ end
48
+
40
49
  def diff_fetch(other)
41
50
  @diff_cache ||= {}
42
51
  @diff_cache[other] ||= yield
43
52
  end
44
53
  end
45
54
  end
46
- end
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_versions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Rodgers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-28 00:00:00.000000000 Z
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport