has_versions 0.9.5 → 0.9.6

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: ea752049fb06dc28b7a1870426655213251cd361
4
- data.tar.gz: 6ae73a71b15133b48701b4830d23a0d05527c02a
3
+ metadata.gz: ae7b9788e9ca7a3aa879653aee867fc8c8d2fb1e
4
+ data.tar.gz: 584cf98bfe7f16a6a6e760166b11c98ecf51db65
5
5
  SHA512:
6
- metadata.gz: d467415baff52c963806c5bdb73a511ace1220e754260aec25f0c45841fe1c3e299ede208e07dc5314ee79ef303b80ff2549a864f3771e164e5989b012e8f7be
7
- data.tar.gz: f8df2c955b94c12391d18fc26201aaa852416a7c43834baf287480d9102d4392065174c1e2aac7e5ee118b64e0c02e82715a9d4c8c625d6217bb29131e03c445
6
+ metadata.gz: 5635cbc68cd4d6c413ac818ef22502442b5be17a79f3e64c546bcebe217804eab69fdde1e4c7a54b7f17ae5b0528ff01a284b180353724d85b325b064a5e1f05
7
+ data.tar.gz: e9d359872eb49c5311693f957a1744b2edef516dc311c576f599e9e2ce935924e9ee4426eaf2fa576ae8a24992bf09b547bf428a27bb6025354d3b5b0d1b4f20
@@ -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.9.5'
4
+ s.version = '0.9.6'
5
5
 
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Grant Rodgers"]
@@ -28,5 +28,5 @@ module HasVersions
28
28
  end
29
29
 
30
30
  ActiveSupport.on_load :cassandra_object do
31
- include HasVersions::Record::Orm::CassandraObject
31
+ extend HasVersions::Record::Orm::CassandraObject
32
32
  end
@@ -7,29 +7,28 @@ module HasVersions
7
7
  def versioned_attributes
8
8
  versioning_configuration.attributes
9
9
  end
10
+
11
+ def create_versioned_attributes(&block)
12
+ versioned_attributes.inject({}) do |memo, attribute|
13
+ if (value = block.call(attribute)).present?
14
+ memo[attribute] = versioning_encode_value(attribute, value)
15
+ end
16
+ memo
17
+ end
18
+ end
10
19
  end
11
20
 
12
21
  def versioned_attributes
13
- create_versioned_attributes do |attribute|
22
+ self.class.create_versioned_attributes do |attribute|
14
23
  self[attribute]
15
24
  end
16
25
  end
17
26
 
18
27
  def versioned_attributes_was
19
- create_versioned_attributes do |attribute|
28
+ self.class.create_versioned_attributes do |attribute|
20
29
  send("#{attribute}_was")
21
30
  end
22
31
  end
23
-
24
- private
25
- def create_versioned_attributes(&block)
26
- self.class.versioned_attributes.inject({}) do |memo, attribute|
27
- if (value = block.call(attribute)).present?
28
- memo[attribute] = versioning_encode_value(attribute, value)
29
- end
30
- memo
31
- end
32
- end
33
32
  end
34
33
  end
35
34
  end
@@ -11,10 +11,6 @@ module HasVersions
11
11
  return if value.nil?
12
12
  attribute_definitions[name.to_sym].coder.decode(value)
13
13
  end
14
-
15
- def versioning_codable?(name)
16
- attribute_definitions.has_key?(name.to_sym)
17
- end
18
14
  end
19
15
  end
20
16
  end
@@ -13,7 +13,7 @@ module HasVersions
13
13
 
14
14
  def reset!(version)
15
15
  self.class.versioned_attributes.each do |attribute|
16
- value = versioning_decode_value(attribute, version.snapshot[attribute])
16
+ value = self.class.versioning_decode_value(attribute, version.snapshot[attribute])
17
17
  send("#{attribute}=", value)
18
18
  end
19
19
  self
@@ -30,7 +30,7 @@ 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])#attribute.to_s#decode_attribute(attribute, snapshot[attribute])
33
+ decoded[attribute] = target.class.versioning_decode_value(attribute, snapshot[attribute])#attribute.to_s#decode_attribute(attribute, snapshot[attribute])
34
34
  end
35
35
  decoded
36
36
  end
@@ -9,7 +9,7 @@ module HasVersions
9
9
 
10
10
  versioning_configuration.attribute :name
11
11
 
12
- def versioning_decode_value(name, value)
12
+ def self.versioning_decode_value(name, value)
13
13
  "hello, #{value}"
14
14
  end
15
15
  end
@@ -11,7 +11,7 @@ module HasVersions
11
11
  versioning_configuration.attribute :name
12
12
  versioning_configuration.attribute :weight
13
13
 
14
- def versioning_decode_value(name, value)
14
+ def self.versioning_decode_value(name, value)
15
15
  "decoded: #{value}"
16
16
  end
17
17
  end
@@ -50,7 +50,7 @@ module HasVersions
50
50
  parent = DiffRecord.version_model.new(target: target, snapshot: {'color' => 'green', 'name' => 'joe', 'weight' => '50'})
51
51
  version = DiffRecord.version_model.new(target: target, parent: parent, snapshot: {'color' => 'green', 'name' => 'sam', 'weight' => '129'})
52
52
  other = DiffRecord.version_model.new(target: target, snapshot: {'color' => 'blue', 'name' => 'sam', 'weight' => '100'})
53
-
53
+
54
54
  assert_equal ['name'], version.applied_modifications(other)
55
55
  assert_equal ['weight'], version.unused_modifications(other)
56
56
  end
@@ -10,16 +10,14 @@ class TestRecord
10
10
  end
11
11
  end
12
12
 
13
- def versioning_encode_value(name, value)
14
- value.to_s
15
- end
16
-
17
- def versioning_decode_value(name, value)
18
- value
19
- end
13
+ class << self
14
+ def versioning_encode_value(name, value)
15
+ value.to_s
16
+ end
20
17
 
21
- def versioning_codable?(name)
22
- true
18
+ def versioning_decode_value(name, value)
19
+ value
20
+ end
23
21
  end
24
22
 
25
23
  def [](attribute)
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.9.5
4
+ version: 0.9.6
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-30 00:00:00.000000000 Z
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport