has_versions 0.6.3 → 0.7.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.
data/has_versions.gemspec
CHANGED
@@ -11,7 +11,9 @@ module HasVersions
|
|
11
11
|
|
12
12
|
def versioned_attributes
|
13
13
|
self.class.versioned_attributes.inject({}) do |memo, attribute|
|
14
|
-
|
14
|
+
if (value = send(attribute)).present?
|
15
|
+
memo[attribute] = versioning_encode_value(attribute, value)
|
16
|
+
end
|
15
17
|
memo
|
16
18
|
end
|
17
19
|
end
|
@@ -5,19 +5,21 @@ module HasVersions
|
|
5
5
|
class AttributesTest < MiniTest::Unit::TestCase
|
6
6
|
class VersionedRecord < TestRecord
|
7
7
|
attr_accessor :name
|
8
|
+
attr_accessor :price
|
8
9
|
attr_accessor :weight
|
9
10
|
attr_accessor :color
|
10
11
|
|
11
12
|
versioning_configuration.attribute :name
|
13
|
+
versioning_configuration.attribute :price
|
12
14
|
versioning_configuration.attribute :weight
|
13
15
|
end
|
14
16
|
|
15
17
|
def test_class_versioned_attributes
|
16
|
-
assert_equal ['name', 'weight'], VersionedRecord.versioned_attributes
|
18
|
+
assert_equal ['name', 'price', 'weight'], VersionedRecord.versioned_attributes
|
17
19
|
end
|
18
20
|
|
19
21
|
def test_instance_versioned_attributes
|
20
|
-
record = VersionedRecord.new(name: 'joe', weight: 142.0, color: 'green')
|
22
|
+
record = VersionedRecord.new(name: 'joe', price: nil, weight: 142.0, color: 'green')
|
21
23
|
expected = {'name' => 'joe', 'weight' => '142.0'}
|
22
24
|
|
23
25
|
assert_equal expected, record.versioned_attributes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_versions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|