active_type 1.1.0 → 1.1.1
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/.travis.yml +7 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.3.2.mysql2.lock +1 -1
- data/Gemfile.3.2.sqlite3.lock +1 -1
- data/Gemfile.4.2.mysql2.lock +1 -1
- data/Gemfile.4.2.pg.lock +1 -1
- data/Gemfile.4.2.sqlite3.lock +1 -1
- data/Gemfile.5.2.mysql2.lock +1 -1
- data/Gemfile.5.2.pg.lock +1 -1
- data/Gemfile.5.2.sqlite3.lock +1 -1
- data/{Gemfile.5.1.pg → Gemfile.6.0.pg} +1 -1
- data/Gemfile.6.0.pg.lock +59 -0
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +32 -2
- metadata +5 -5
- data/Gemfile.5.1.pg.lock +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dd2986e6945783f4c52776074f66d614ecbbcef28f5eb1471ebf450dd68c8d2
|
|
4
|
+
data.tar.gz: 763be8835f5184df763527d0b10b8af06edf12168a8d76ebc67951680e097cb7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 301557809bffecdb33705cb01d68a1da237d6d0d30e726239e8c2af57c59eeb81c8c3287796f49c76abe0c4a65ab4196d4d23374224c0796ae207355f58e6019
|
|
7
|
+
data.tar.gz: bebb85d3edc8733b3816ee82925659a804836eaddc20d100c171a1eeb034134e3159de414d62fadc406d243c13b4ed4116b74127e777bf9da1d9872af7c3ea2b
|
data/.travis.yml
CHANGED
|
@@ -9,10 +9,10 @@ gemfile:
|
|
|
9
9
|
- Gemfile.4.2.mysql2
|
|
10
10
|
- Gemfile.4.2.pg
|
|
11
11
|
- Gemfile.4.2.sqlite3
|
|
12
|
-
- Gemfile.5.1.pg
|
|
13
12
|
- Gemfile.5.2.mysql2
|
|
14
13
|
- Gemfile.5.2.sqlite3
|
|
15
14
|
- Gemfile.5.2.pg
|
|
15
|
+
- Gemfile.6.0.pg
|
|
16
16
|
before_script:
|
|
17
17
|
- psql -c 'create database active_type_test;' -U postgres
|
|
18
18
|
- mysql -e 'create database IF NOT EXISTS active_type_test;'
|
|
@@ -38,5 +38,11 @@ matrix:
|
|
|
38
38
|
gemfile: Gemfile.4.2.pg
|
|
39
39
|
- rvm: "2.5.3"
|
|
40
40
|
gemfile: Gemfile.4.2.sqlite3
|
|
41
|
+
- rvm: "2.3.8"
|
|
42
|
+
gemfile: Gemfile.6.0.pg
|
|
43
|
+
- rvm: "2.4.5"
|
|
44
|
+
gemfile: Gemfile.6.0.pg
|
|
41
45
|
install:
|
|
42
46
|
- bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
|
47
|
+
addons:
|
|
48
|
+
postgresql: 9.3
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 1.1.1 (2019-05-07)
|
|
6
|
+
|
|
7
|
+
* Improved dirty tracking (`#changes?` etc) for virtual attributes to bring it more in line with
|
|
8
|
+
the behaviour of non-virtual attributes. Behaviour with ActiveRecord < 4 remains unchanged.
|
|
9
|
+
Thanks to @lowski.
|
|
10
|
+
|
|
5
11
|
## 1.1.0 (2019-03-04)
|
|
6
12
|
|
|
7
13
|
* For some use cases, users need to access ActiveRecord's original `.attribute` method, which ActiveType overrides. We now alias `.attribute` as `.ar_attribute`.
|
data/Gemfile.3.2.mysql2.lock
CHANGED
data/Gemfile.3.2.sqlite3.lock
CHANGED
data/Gemfile.4.2.mysql2.lock
CHANGED
data/Gemfile.4.2.pg.lock
CHANGED
data/Gemfile.4.2.sqlite3.lock
CHANGED
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
data/Gemfile.5.2.sqlite3.lock
CHANGED
data/Gemfile.6.0.pg.lock
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (1.1.1)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (6.0.0.beta3)
|
|
11
|
+
activesupport (= 6.0.0.beta3)
|
|
12
|
+
activerecord (6.0.0.beta3)
|
|
13
|
+
activemodel (= 6.0.0.beta3)
|
|
14
|
+
activesupport (= 6.0.0.beta3)
|
|
15
|
+
activesupport (6.0.0.beta3)
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
|
+
i18n (>= 0.7, < 2)
|
|
18
|
+
minitest (~> 5.1)
|
|
19
|
+
tzinfo (~> 1.1)
|
|
20
|
+
zeitwerk (~> 1.3, >= 1.3.1)
|
|
21
|
+
concurrent-ruby (1.1.5)
|
|
22
|
+
diff-lcs (1.3)
|
|
23
|
+
gemika (0.3.4)
|
|
24
|
+
i18n (1.6.0)
|
|
25
|
+
concurrent-ruby (~> 1.0)
|
|
26
|
+
minitest (5.11.3)
|
|
27
|
+
pg (1.1.4)
|
|
28
|
+
rake (12.3.2)
|
|
29
|
+
rspec (3.8.0)
|
|
30
|
+
rspec-core (~> 3.8.0)
|
|
31
|
+
rspec-expectations (~> 3.8.0)
|
|
32
|
+
rspec-mocks (~> 3.8.0)
|
|
33
|
+
rspec-core (3.8.0)
|
|
34
|
+
rspec-support (~> 3.8.0)
|
|
35
|
+
rspec-expectations (3.8.2)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.8.0)
|
|
38
|
+
rspec-mocks (3.8.0)
|
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
+
rspec-support (~> 3.8.0)
|
|
41
|
+
rspec-support (3.8.0)
|
|
42
|
+
thread_safe (0.3.6)
|
|
43
|
+
tzinfo (1.2.5)
|
|
44
|
+
thread_safe (~> 0.1)
|
|
45
|
+
zeitwerk (1.4.3)
|
|
46
|
+
|
|
47
|
+
PLATFORMS
|
|
48
|
+
ruby
|
|
49
|
+
|
|
50
|
+
DEPENDENCIES
|
|
51
|
+
active_type!
|
|
52
|
+
activerecord (~> 6.0.0beta)
|
|
53
|
+
gemika
|
|
54
|
+
pg
|
|
55
|
+
rake
|
|
56
|
+
rspec (~> 3.4)
|
|
57
|
+
|
|
58
|
+
BUNDLED WITH
|
|
59
|
+
1.16.6
|
data/lib/active_type/version.rb
CHANGED
|
@@ -75,13 +75,13 @@ module ActiveType
|
|
|
75
75
|
def build_dirty_tracking_methods(name)
|
|
76
76
|
@module.module_eval <<-BODY, __FILE__, __LINE__ + 1
|
|
77
77
|
def #{name}_was
|
|
78
|
-
|
|
78
|
+
virtual_attributes_were["#{name}"]
|
|
79
79
|
end
|
|
80
80
|
BODY
|
|
81
81
|
|
|
82
82
|
@module.module_eval <<-BODY, __FILE__, __LINE__ + 1
|
|
83
83
|
def #{name}_changed?
|
|
84
|
-
|
|
84
|
+
#{name} != virtual_attributes_were["#{name}"]
|
|
85
85
|
end
|
|
86
86
|
BODY
|
|
87
87
|
|
|
@@ -125,6 +125,7 @@ module ActiveType
|
|
|
125
125
|
def initialize_dup(other)
|
|
126
126
|
@virtual_attributes_cache = {}
|
|
127
127
|
@virtual_attributes = VirtualAttributes.deep_dup(virtual_attributes)
|
|
128
|
+
@virtual_attributes_were = VirtualAttributes.deep_dup(virtual_attributes_were)
|
|
128
129
|
|
|
129
130
|
super
|
|
130
131
|
end
|
|
@@ -133,6 +134,10 @@ module ActiveType
|
|
|
133
134
|
@virtual_attributes ||= {}
|
|
134
135
|
end
|
|
135
136
|
|
|
137
|
+
def virtual_attributes_were
|
|
138
|
+
@virtual_attributes_were ||= {}
|
|
139
|
+
end
|
|
140
|
+
|
|
136
141
|
def virtual_attributes_cache
|
|
137
142
|
@virtual_attributes_cache ||= {}
|
|
138
143
|
end
|
|
@@ -168,6 +173,31 @@ module ActiveType
|
|
|
168
173
|
end
|
|
169
174
|
end
|
|
170
175
|
|
|
176
|
+
def changed?
|
|
177
|
+
self.class._virtual_column_names.any? { |attr| virtual_attributes_were[attr] != send(attr) } || super
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def changes
|
|
181
|
+
changes = self.class._virtual_column_names.each_with_object({}) do |attr, changes|
|
|
182
|
+
current_value = send(attr)
|
|
183
|
+
previous_value = virtual_attributes_were[attr]
|
|
184
|
+
changes[attr] = [previous_value, current_value] if previous_value != current_value
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
super.merge(changes)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
|
191
|
+
def changes_applied
|
|
192
|
+
super
|
|
193
|
+
|
|
194
|
+
virtual_attributes.each do |attr, _|
|
|
195
|
+
value = read_virtual_attribute(attr)
|
|
196
|
+
virtual_attributes_were[attr] = value.duplicable? ? value.clone : value
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
171
201
|
def read_virtual_attribute(name)
|
|
172
202
|
name = name.to_s
|
|
173
203
|
if virtual_attributes_cache.has_key?(name)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2019-
|
|
12
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -75,14 +75,14 @@ files:
|
|
|
75
75
|
- Gemfile.4.2.pg.lock
|
|
76
76
|
- Gemfile.4.2.sqlite3
|
|
77
77
|
- Gemfile.4.2.sqlite3.lock
|
|
78
|
-
- Gemfile.5.1.pg
|
|
79
|
-
- Gemfile.5.1.pg.lock
|
|
80
78
|
- Gemfile.5.2.mysql2
|
|
81
79
|
- Gemfile.5.2.mysql2.lock
|
|
82
80
|
- Gemfile.5.2.pg
|
|
83
81
|
- Gemfile.5.2.pg.lock
|
|
84
82
|
- Gemfile.5.2.sqlite3
|
|
85
83
|
- Gemfile.5.2.sqlite3.lock
|
|
84
|
+
- Gemfile.6.0.pg
|
|
85
|
+
- Gemfile.6.0.pg.lock
|
|
86
86
|
- Gemfile.lock
|
|
87
87
|
- LICENSE
|
|
88
88
|
- README.md
|
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
123
123
|
version: '0'
|
|
124
124
|
requirements: []
|
|
125
125
|
rubyforge_project:
|
|
126
|
-
rubygems_version: 2.7.
|
|
126
|
+
rubygems_version: 2.7.7
|
|
127
127
|
signing_key:
|
|
128
128
|
specification_version: 4
|
|
129
129
|
summary: Make any Ruby object quack like ActiveRecord
|
data/Gemfile.5.1.pg.lock
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
active_type (1.1.0)
|
|
5
|
-
activerecord (>= 3.2)
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: https://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (5.1.6.1)
|
|
11
|
-
activesupport (= 5.1.6.1)
|
|
12
|
-
activerecord (5.1.6.1)
|
|
13
|
-
activemodel (= 5.1.6.1)
|
|
14
|
-
activesupport (= 5.1.6.1)
|
|
15
|
-
arel (~> 8.0)
|
|
16
|
-
activesupport (5.1.6.1)
|
|
17
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
18
|
-
i18n (>= 0.7, < 2)
|
|
19
|
-
minitest (~> 5.1)
|
|
20
|
-
tzinfo (~> 1.1)
|
|
21
|
-
arel (8.0.0)
|
|
22
|
-
concurrent-ruby (1.1.4)
|
|
23
|
-
diff-lcs (1.3)
|
|
24
|
-
gemika (0.3.4)
|
|
25
|
-
i18n (1.5.3)
|
|
26
|
-
concurrent-ruby (~> 1.0)
|
|
27
|
-
minitest (5.11.3)
|
|
28
|
-
pg (0.21.0)
|
|
29
|
-
rake (12.0.0)
|
|
30
|
-
rspec (3.6.0)
|
|
31
|
-
rspec-core (~> 3.6.0)
|
|
32
|
-
rspec-expectations (~> 3.6.0)
|
|
33
|
-
rspec-mocks (~> 3.6.0)
|
|
34
|
-
rspec-core (3.6.0)
|
|
35
|
-
rspec-support (~> 3.6.0)
|
|
36
|
-
rspec-expectations (3.6.0)
|
|
37
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
-
rspec-support (~> 3.6.0)
|
|
39
|
-
rspec-mocks (3.6.0)
|
|
40
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
-
rspec-support (~> 3.6.0)
|
|
42
|
-
rspec-support (3.6.0)
|
|
43
|
-
thread_safe (0.3.6)
|
|
44
|
-
tzinfo (1.2.5)
|
|
45
|
-
thread_safe (~> 0.1)
|
|
46
|
-
|
|
47
|
-
PLATFORMS
|
|
48
|
-
ruby
|
|
49
|
-
|
|
50
|
-
DEPENDENCIES
|
|
51
|
-
active_type!
|
|
52
|
-
activerecord (~> 5.1.0)
|
|
53
|
-
gemika
|
|
54
|
-
pg
|
|
55
|
-
rake
|
|
56
|
-
rspec (~> 3.4)
|
|
57
|
-
|
|
58
|
-
BUNDLED WITH
|
|
59
|
-
1.16.6
|