couch_potato 1.6.4 → 1.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 +5 -5
- data/.github/workflows/ruby.yml +38 -0
- data/.gitignore +3 -0
- data/CHANGES.md +193 -122
- data/Gemfile +4 -0
- data/README.md +61 -85
- data/Rakefile +11 -10
- data/couch_potato-rspec.gemspec +3 -2
- data/couch_potato.gemspec +9 -7
- data/gemfiles/active_support_5_0 +7 -0
- data/gemfiles/active_support_5_1 +7 -0
- data/gemfiles/active_support_5_2 +7 -0
- data/gemfiles/active_support_6_0 +7 -0
- data/gemfiles/active_support_6_1 +7 -0
- data/lib/couch_potato/database.rb +168 -71
- data/lib/couch_potato/persistence/dirty_attributes.rb +3 -21
- data/lib/couch_potato/persistence/magic_timestamps.rb +3 -3
- data/lib/couch_potato/persistence/properties.rb +15 -10
- data/lib/couch_potato/persistence/revisions.rb +14 -0
- data/lib/couch_potato/persistence/simple_property.rb +0 -4
- data/lib/couch_potato/persistence/type_caster.rb +11 -6
- data/lib/couch_potato/persistence.rb +5 -3
- data/lib/couch_potato/railtie.rb +7 -12
- data/lib/couch_potato/validation.rb +8 -0
- data/lib/couch_potato/version.rb +2 -2
- data/lib/couch_potato/view/base_view_spec.rb +8 -32
- data/lib/couch_potato/view/custom_views.rb +4 -3
- data/lib/couch_potato/view/flex_view_spec.rb +121 -0
- data/lib/couch_potato/view/view_parameters.rb +34 -0
- data/lib/couch_potato.rb +37 -16
- data/spec/callbacks_spec.rb +45 -19
- data/spec/conflict_handling_spec.rb +1 -2
- data/spec/property_spec.rb +12 -3
- data/spec/railtie_spec.rb +17 -1
- data/spec/revisions_spec.rb +25 -0
- data/spec/spec_helper.rb +4 -3
- data/spec/unit/active_model_compliance_spec.rb +7 -3
- data/spec/unit/attributes_spec.rb +54 -1
- data/spec/unit/caching_spec.rb +105 -0
- data/spec/unit/couch_potato_spec.rb +70 -5
- data/spec/unit/create_spec.rb +5 -4
- data/spec/unit/database_spec.rb +235 -135
- data/spec/unit/dirty_attributes_spec.rb +5 -26
- data/spec/unit/flex_view_spec_spec.rb +17 -0
- data/spec/unit/model_view_spec_spec.rb +1 -1
- data/spec/unit/rspec_stub_db_spec.rb +31 -0
- data/spec/unit/validation_spec.rb +42 -2
- data/spec/views_spec.rb +214 -103
- data/vendor/pouchdb-collate/LICENSE +202 -0
- data/vendor/pouchdb-collate/pouchdb-collate.js +430 -0
- metadata +46 -33
- data/.ruby-version +0 -1
- data/.travis.yml +0 -20
- data/gemfiles/active_support_4_0 +0 -11
- data/gemfiles/active_support_4_1 +0 -11
- data/gemfiles/active_support_4_2 +0 -11
- data/lib/couch_potato/persistence/deep_dirty_attributes.rb +0 -180
- data/spec/unit/deep_dirty_attributes_spec.rb +0 -434
metadata
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: couch_potato
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Lang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: activemodel
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5.0'
|
|
20
|
+
- - "<"
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
22
|
+
version: '7.0'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '5.0'
|
|
30
|
+
- - "<"
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
32
|
+
version: '7.0'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: couchrest
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.0.0
|
|
39
|
+
version: 2.0.0
|
|
34
40
|
type: :runtime
|
|
35
41
|
prerelease: false
|
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
43
|
requirements:
|
|
38
44
|
- - "~>"
|
|
39
45
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.0.0
|
|
46
|
+
version: 2.0.0
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
48
|
+
name: json
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
44
50
|
requirements:
|
|
45
51
|
- - "~>"
|
|
46
52
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
53
|
+
version: '2.3'
|
|
48
54
|
type: :runtime
|
|
49
55
|
prerelease: false
|
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
57
|
requirements:
|
|
52
58
|
- - "~>"
|
|
53
59
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
60
|
+
version: '2.3'
|
|
55
61
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
62
|
+
name: rake
|
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
|
58
64
|
requirements:
|
|
59
65
|
- - "~>"
|
|
60
66
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
67
|
+
version: '12.0'
|
|
62
68
|
type: :development
|
|
63
69
|
prerelease: false
|
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
71
|
requirements:
|
|
66
72
|
- - "~>"
|
|
67
73
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
74
|
+
version: '12.0'
|
|
69
75
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
76
|
+
name: rspec
|
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
|
72
78
|
requirements:
|
|
73
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
74
80
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
81
|
+
version: 3.5.0
|
|
76
82
|
type: :development
|
|
77
83
|
prerelease: false
|
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
85
|
requirements:
|
|
80
|
-
- - "
|
|
86
|
+
- - "~>"
|
|
81
87
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
88
|
+
version: 3.5.0
|
|
83
89
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
90
|
+
name: timecop
|
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
|
86
92
|
requirements:
|
|
87
93
|
- - ">="
|
|
@@ -95,7 +101,7 @@ dependencies:
|
|
|
95
101
|
- !ruby/object:Gem::Version
|
|
96
102
|
version: '0'
|
|
97
103
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
104
|
+
name: tzinfo
|
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
|
100
106
|
requirements:
|
|
101
107
|
- - ">="
|
|
@@ -114,9 +120,8 @@ executables: []
|
|
|
114
120
|
extensions: []
|
|
115
121
|
extra_rdoc_files: []
|
|
116
122
|
files:
|
|
123
|
+
- ".github/workflows/ruby.yml"
|
|
117
124
|
- ".gitignore"
|
|
118
|
-
- ".ruby-version"
|
|
119
|
-
- ".travis.yml"
|
|
120
125
|
- CHANGES.md
|
|
121
126
|
- CREDITS
|
|
122
127
|
- Gemfile
|
|
@@ -125,9 +130,11 @@ files:
|
|
|
125
130
|
- Rakefile
|
|
126
131
|
- couch_potato-rspec.gemspec
|
|
127
132
|
- couch_potato.gemspec
|
|
128
|
-
- gemfiles/
|
|
129
|
-
- gemfiles/
|
|
130
|
-
- gemfiles/
|
|
133
|
+
- gemfiles/active_support_5_0
|
|
134
|
+
- gemfiles/active_support_5_1
|
|
135
|
+
- gemfiles/active_support_5_2
|
|
136
|
+
- gemfiles/active_support_6_0
|
|
137
|
+
- gemfiles/active_support_6_1
|
|
131
138
|
- init.rb
|
|
132
139
|
- lib/core_ext/date.rb
|
|
133
140
|
- lib/core_ext/time.rb
|
|
@@ -139,13 +146,13 @@ files:
|
|
|
139
146
|
- lib/couch_potato/persistence/active_model_compliance.rb
|
|
140
147
|
- lib/couch_potato/persistence/attachments.rb
|
|
141
148
|
- lib/couch_potato/persistence/callbacks.rb
|
|
142
|
-
- lib/couch_potato/persistence/deep_dirty_attributes.rb
|
|
143
149
|
- lib/couch_potato/persistence/deep_tracked_property.rb
|
|
144
150
|
- lib/couch_potato/persistence/dirty_attributes.rb
|
|
145
151
|
- lib/couch_potato/persistence/ghost_attributes.rb
|
|
146
152
|
- lib/couch_potato/persistence/json.rb
|
|
147
153
|
- lib/couch_potato/persistence/magic_timestamps.rb
|
|
148
154
|
- lib/couch_potato/persistence/properties.rb
|
|
155
|
+
- lib/couch_potato/persistence/revisions.rb
|
|
149
156
|
- lib/couch_potato/persistence/simple_property.rb
|
|
150
157
|
- lib/couch_potato/persistence/type_caster.rb
|
|
151
158
|
- lib/couch_potato/railtie.rb
|
|
@@ -154,10 +161,12 @@ files:
|
|
|
154
161
|
- lib/couch_potato/view/base_view_spec.rb
|
|
155
162
|
- lib/couch_potato/view/custom_view_spec.rb
|
|
156
163
|
- lib/couch_potato/view/custom_views.rb
|
|
164
|
+
- lib/couch_potato/view/flex_view_spec.rb
|
|
157
165
|
- lib/couch_potato/view/lists.rb
|
|
158
166
|
- lib/couch_potato/view/model_view_spec.rb
|
|
159
167
|
- lib/couch_potato/view/properties_view_spec.rb
|
|
160
168
|
- lib/couch_potato/view/raw_view_spec.rb
|
|
169
|
+
- lib/couch_potato/view/view_parameters.rb
|
|
161
170
|
- lib/couch_potato/view/view_query.rb
|
|
162
171
|
- rails/reload_classes.rb
|
|
163
172
|
- spec/attachments_spec.rb
|
|
@@ -172,11 +181,13 @@ files:
|
|
|
172
181
|
- spec/rails_spec.rb
|
|
173
182
|
- spec/railtie_spec.rb
|
|
174
183
|
- spec/reload_spec.rb
|
|
184
|
+
- spec/revisions_spec.rb
|
|
175
185
|
- spec/spec.opts
|
|
176
186
|
- spec/spec_helper.rb
|
|
177
187
|
- spec/unit/active_model_compliance_spec.rb
|
|
178
188
|
- spec/unit/attributes_spec.rb
|
|
179
189
|
- spec/unit/base_view_spec_spec.rb
|
|
190
|
+
- spec/unit/caching_spec.rb
|
|
180
191
|
- spec/unit/callbacks_spec.rb
|
|
181
192
|
- spec/unit/couch_potato_spec.rb
|
|
182
193
|
- spec/unit/create_spec.rb
|
|
@@ -184,8 +195,8 @@ files:
|
|
|
184
195
|
- spec/unit/custom_views_spec.rb
|
|
185
196
|
- spec/unit/database_spec.rb
|
|
186
197
|
- spec/unit/date_spec.rb
|
|
187
|
-
- spec/unit/deep_dirty_attributes_spec.rb
|
|
188
198
|
- spec/unit/dirty_attributes_spec.rb
|
|
199
|
+
- spec/unit/flex_view_spec_spec.rb
|
|
189
200
|
- spec/unit/forbidden_attributes_protection_spec.rb
|
|
190
201
|
- spec/unit/initialize_spec.rb
|
|
191
202
|
- spec/unit/json_spec.rb
|
|
@@ -202,6 +213,8 @@ files:
|
|
|
202
213
|
- spec/update_spec.rb
|
|
203
214
|
- spec/view_updates_spec.rb
|
|
204
215
|
- spec/views_spec.rb
|
|
216
|
+
- vendor/pouchdb-collate/LICENSE
|
|
217
|
+
- vendor/pouchdb-collate/pouchdb-collate.js
|
|
205
218
|
homepage: http://github.com/langalex/couch_potato
|
|
206
219
|
licenses: []
|
|
207
220
|
metadata: {}
|
|
@@ -220,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
220
233
|
- !ruby/object:Gem::Version
|
|
221
234
|
version: '0'
|
|
222
235
|
requirements: []
|
|
223
|
-
|
|
224
|
-
rubygems_version: 2.4.7
|
|
236
|
+
rubygems_version: 3.1.6
|
|
225
237
|
signing_key:
|
|
226
238
|
specification_version: 4
|
|
227
239
|
summary: Ruby persistence layer for CouchDB
|
|
@@ -238,11 +250,13 @@ test_files:
|
|
|
238
250
|
- spec/rails_spec.rb
|
|
239
251
|
- spec/railtie_spec.rb
|
|
240
252
|
- spec/reload_spec.rb
|
|
253
|
+
- spec/revisions_spec.rb
|
|
241
254
|
- spec/spec.opts
|
|
242
255
|
- spec/spec_helper.rb
|
|
243
256
|
- spec/unit/active_model_compliance_spec.rb
|
|
244
257
|
- spec/unit/attributes_spec.rb
|
|
245
258
|
- spec/unit/base_view_spec_spec.rb
|
|
259
|
+
- spec/unit/caching_spec.rb
|
|
246
260
|
- spec/unit/callbacks_spec.rb
|
|
247
261
|
- spec/unit/couch_potato_spec.rb
|
|
248
262
|
- spec/unit/create_spec.rb
|
|
@@ -250,8 +264,8 @@ test_files:
|
|
|
250
264
|
- spec/unit/custom_views_spec.rb
|
|
251
265
|
- spec/unit/database_spec.rb
|
|
252
266
|
- spec/unit/date_spec.rb
|
|
253
|
-
- spec/unit/deep_dirty_attributes_spec.rb
|
|
254
267
|
- spec/unit/dirty_attributes_spec.rb
|
|
268
|
+
- spec/unit/flex_view_spec_spec.rb
|
|
255
269
|
- spec/unit/forbidden_attributes_protection_spec.rb
|
|
256
270
|
- spec/unit/initialize_spec.rb
|
|
257
271
|
- spec/unit/json_spec.rb
|
|
@@ -267,4 +281,3 @@ test_files:
|
|
|
267
281
|
- spec/update_spec.rb
|
|
268
282
|
- spec/view_updates_spec.rb
|
|
269
283
|
- spec/views_spec.rb
|
|
270
|
-
has_rdoc:
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.2.2
|
data/.travis.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
rvm:
|
|
2
|
-
- 2.0.0
|
|
3
|
-
- 2.1.2
|
|
4
|
-
- 2.2.2
|
|
5
|
-
- jruby-9.0.1.0
|
|
6
|
-
- rbx-2.5.8
|
|
7
|
-
services:
|
|
8
|
-
- couchdb
|
|
9
|
-
gemfile:
|
|
10
|
-
- gemfiles/active_support_4_0
|
|
11
|
-
- gemfiles/active_support_4_1
|
|
12
|
-
- gemfiles/active_support_4_2
|
|
13
|
-
before_install:
|
|
14
|
-
gem install bundler --version 1.11.2
|
|
15
|
-
before_script:
|
|
16
|
-
- sudo sh -c 'echo "[native_query_servers]" >> /etc/couchdb/local.ini'
|
|
17
|
-
- sudo sh -c 'echo "erlang = {couch_native_process, start_link, []}" >> /etc/couchdb/local.ini'
|
|
18
|
-
- sudo /etc/init.d/couchdb restart
|
|
19
|
-
- bundle
|
|
20
|
-
script: bundle exec rake
|
data/gemfiles/active_support_4_0
DELETED
data/gemfiles/active_support_4_1
DELETED
data/gemfiles/active_support_4_2
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
module CouchPotato
|
|
2
|
-
module Persistence
|
|
3
|
-
module DeepDirtyAttributes
|
|
4
|
-
|
|
5
|
-
def self.included(base) #:nodoc:
|
|
6
|
-
base.send :extend, ClassMethods
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def initialize(*args, &block)
|
|
10
|
-
super(*args, &block)
|
|
11
|
-
reset_deep_dirty_attributes
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def changed?
|
|
15
|
-
super || self.class.deep_tracked_properties.any? do |property|
|
|
16
|
-
send("#{property.name}_changed?")
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def changes
|
|
21
|
-
changes = super
|
|
22
|
-
if @original_deep_values
|
|
23
|
-
self.class.deep_tracked_properties.each do |property|
|
|
24
|
-
if send("#{property.name}_changed?")
|
|
25
|
-
changes[property.name] = send("#{property.name}_change")
|
|
26
|
-
else
|
|
27
|
-
changes.delete property.name
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
changes
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def reset_dirty_attributes
|
|
37
|
-
super
|
|
38
|
-
reset_deep_dirty_attributes
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def reset_deep_dirty_attributes
|
|
42
|
-
@original_deep_values = HashWithIndifferentAccess.new
|
|
43
|
-
self.class.deep_tracked_properties.each do |property|
|
|
44
|
-
value = send(property.name)
|
|
45
|
-
if value
|
|
46
|
-
if doc?(value)
|
|
47
|
-
value.send(:reset_dirty_attributes)
|
|
48
|
-
elsif value.respond_to?(:each)
|
|
49
|
-
value.each do |item|
|
|
50
|
-
item.send(:reset_dirty_attributes) if doc?(item)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
@original_deep_values[property.name] = clone_attribute(value)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def doc_changed?(name)
|
|
59
|
-
old, new = @original_deep_values[name], send(name)
|
|
60
|
-
if old.nil? && new.nil?
|
|
61
|
-
false
|
|
62
|
-
elsif old.nil? ^ new.nil?
|
|
63
|
-
true
|
|
64
|
-
else
|
|
65
|
-
(doc?(new) && new.changed?) || old.to_hash != new.to_hash
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def simple_array_changed?(name)
|
|
70
|
-
@original_deep_values[name] != send(name)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def doc_array_changed?(name)
|
|
74
|
-
old, new = @original_deep_values[name], send(name)
|
|
75
|
-
if old.blank? && new.blank?
|
|
76
|
-
false
|
|
77
|
-
elsif old.blank? ^ new.blank?
|
|
78
|
-
true
|
|
79
|
-
else
|
|
80
|
-
old != new || old.map(&:to_hash) != new.map(&:to_hash)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def doc?(value)
|
|
85
|
-
value && value.respond_to?(:changed?)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def doc_change(name)
|
|
89
|
-
old, new = @original_deep_values[name], send(name)
|
|
90
|
-
if !old || !new || old != new
|
|
91
|
-
[old, new]
|
|
92
|
-
else
|
|
93
|
-
[old, doc_diff(old, new)]
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def doc_diff(old, new)
|
|
98
|
-
clone = clone_attribute(old)
|
|
99
|
-
clone.attributes = new.attributes
|
|
100
|
-
clone.changes
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def simple_array_change(name)
|
|
104
|
-
value = send(name) || []
|
|
105
|
-
old = @original_deep_values[name] || []
|
|
106
|
-
changes = HashWithIndifferentAccess.new :added => value - old, :removed => old - value
|
|
107
|
-
[old, changes]
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def doc_array_change(name)
|
|
111
|
-
old = @original_deep_values[name] || []
|
|
112
|
-
value = send(name)
|
|
113
|
-
|
|
114
|
-
added = value - old
|
|
115
|
-
removed = old - value
|
|
116
|
-
changed = value.map do |value_item|
|
|
117
|
-
old_item = old.detect {|i| i == value_item}
|
|
118
|
-
if old_item
|
|
119
|
-
changes = doc_diff(old_item, value_item)
|
|
120
|
-
unless changes.empty?
|
|
121
|
-
[old_item, changes]
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end.compact
|
|
125
|
-
changes = HashWithIndifferentAccess.new(:added => added, :removed => removed, :changed => changed)
|
|
126
|
-
|
|
127
|
-
[old, changes]
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
module ClassMethods #:nodoc:
|
|
131
|
-
def property(name, options = {})
|
|
132
|
-
super
|
|
133
|
-
if deep_trackable_type?(options[:type])
|
|
134
|
-
index = properties.find_index {|p| p.name == name}
|
|
135
|
-
properties.list[index] = DeepTrackedProperty.new(self, name, options)
|
|
136
|
-
end
|
|
137
|
-
remove_attribute_dirty_methods_from_activesupport_module
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def remove_attribute_dirty_methods_from_activesupport_module
|
|
141
|
-
methods = deep_tracked_property_names.flat_map {|n| ["#{n}_changed?", "#{n}_change", "#{n}_was"]}.map(&:to_sym)
|
|
142
|
-
activesupport_modules = ancestors.select {|m| m.name.nil? && (methods - m.instance_methods).empty?}
|
|
143
|
-
activesupport_modules.each do |mod|
|
|
144
|
-
methods.each do |method|
|
|
145
|
-
mod.send :remove_method, method if mod.instance_methods.include?(method)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def doc_array_type?(type)
|
|
151
|
-
type && type.is_a?(Array) && doc_type?(type[0])
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def simple_array_type?(type)
|
|
155
|
-
type && type.is_a?(Array) && !doc_type?(type[0])
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def doc_type?(type)
|
|
159
|
-
type &&
|
|
160
|
-
type.respond_to?(:included_modules) &&
|
|
161
|
-
type.included_modules.include?(DirtyAttributes)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def deep_trackable_type?(type)
|
|
165
|
-
type && type.is_a?(Array) || doc_type?(type)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def deep_tracked_properties
|
|
169
|
-
properties.select do |property|
|
|
170
|
-
property.is_a? DeepTrackedProperty
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def deep_tracked_property_names
|
|
175
|
-
deep_tracked_properties.map(&:name)
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
end
|