has_versions 0.7.2 → 0.8.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 +4 -4
- data/has_versions.gemspec +1 -1
- data/lib/has_versions/record.rb +0 -1
- data/lib/has_versions/record/attributes.rb +0 -8
- data/lib/has_versions/record/configuration.rb +0 -5
- data/test/has_versions/record/attributes_test.rb +0 -21
- data/test/has_versions/record/configuration_test.rb +0 -9
- data/test/has_versions/record_test.rb +0 -4
- data/test/support/test_version.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8b422b5420880774f2c762226fe857089fa499
|
4
|
+
data.tar.gz: 879836886df8c06af5f1faa92718f3a22da8eaa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec00d321511442b133f24249c4a1b303cb8ce1a70c2c3e27cc221c9e4e887b6e855cb9b16977f248b07c3b876ef70cab966987db81f80e734d9512c000d3328a
|
7
|
+
data.tar.gz: 1388cfa1208f095bc8dc2684005c9323c785c28a37fca1c336811cf22a0b987a2f28022e78b3dc1b0dd2f0e5abd00c8ecfa254a79235b0b3002b67776c887b9c
|
data/has_versions.gemspec
CHANGED
data/lib/has_versions/record.rb
CHANGED
@@ -21,14 +21,6 @@ module HasVersions
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def associated_versions
|
25
|
-
if versioning_configuration.associated_versions_callback
|
26
|
-
instance_eval(&versioning_configuration.associated_versions_callback).compact
|
27
|
-
else
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
24
|
private
|
33
25
|
def create_versioned_attributes(&block)
|
34
26
|
self.class.versioned_attributes.inject({}) do |memo, attribute|
|
@@ -2,7 +2,6 @@ module HasVersions
|
|
2
2
|
module Record
|
3
3
|
class Configuration
|
4
4
|
attr_accessor :attributes
|
5
|
-
attr_accessor :associated_versions_callback
|
6
5
|
|
7
6
|
def initialize
|
8
7
|
self.attributes = []
|
@@ -11,10 +10,6 @@ module HasVersions
|
|
11
10
|
def attribute(name)
|
12
11
|
attributes << name.to_s
|
13
12
|
end
|
14
|
-
|
15
|
-
def associated_versions(&block)
|
16
|
-
self.associated_versions_callback = block
|
17
|
-
end
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
@@ -24,27 +24,6 @@ module HasVersions
|
|
24
24
|
|
25
25
|
assert_equal expected, record.versioned_attributes
|
26
26
|
end
|
27
|
-
|
28
|
-
# def test_instance_versioned_attributes_was
|
29
|
-
# record = VersionedRecord.new(name: 'joe', price: nil, weight: 142.0, color: 'green')
|
30
|
-
# expected = {'name' => 'joe', 'weight' => '142.0'}
|
31
|
-
#
|
32
|
-
# assert_equal expected, record.versioned_attributes_was
|
33
|
-
# end
|
34
|
-
|
35
|
-
def test_associated_versions_when_defined
|
36
|
-
model = Class.new(VersionedRecord) do
|
37
|
-
versioning_configuration.associated_versions do
|
38
|
-
["#{name} Hendrix", nil]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_equal ["Jimi Hendrix"], model.new(name: "Jimi").associated_versions
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_associated_versions_when_not_defined
|
46
|
-
assert_nil VersionedRecord.new.associated_versions
|
47
|
-
end
|
48
27
|
end
|
49
28
|
end
|
50
29
|
end
|
@@ -10,15 +10,6 @@ module HasVersions
|
|
10
10
|
|
11
11
|
assert_equal %w(foo bar), configuration.attributes
|
12
12
|
end
|
13
|
-
|
14
|
-
def test_associated_versions
|
15
|
-
configuration = HasVersions::Record::Configuration.new
|
16
|
-
configuration.associated_versions do
|
17
|
-
"poop"
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_equal "poop", configuration.associated_versions_callback.call
|
21
|
-
end
|
22
13
|
end
|
23
14
|
end
|
24
15
|
end
|
@@ -15,16 +15,12 @@ module HasVersions
|
|
15
15
|
record = Class.new(TestRecord) do
|
16
16
|
attr_accessor :name
|
17
17
|
versioning_configuration.attribute :name
|
18
|
-
versioning_configuration.associated_versions do
|
19
|
-
["hola"]
|
20
|
-
end
|
21
18
|
end.new(name: 'wee')
|
22
19
|
|
23
20
|
version = record.to_version
|
24
21
|
|
25
22
|
assert_kind_of TestVersion, version
|
26
23
|
assert_equal record, version.target
|
27
|
-
assert_equal ["hola"], version.associated_versions
|
28
24
|
assert_equal record.versioned_attributes, version.snapshot
|
29
25
|
end
|
30
26
|
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.
|
4
|
+
version: 0.8.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-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project: has_versions
|
98
|
-
rubygems_version: 2.0.
|
98
|
+
rubygems_version: 2.0.2
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: ActiveModel versioning
|