active_data 1.0.0 → 1.1.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.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +13 -0
  3. data/.rubocop.yml +56 -0
  4. data/.rubocop_todo.yml +53 -0
  5. data/.rvmrc +1 -1
  6. data/.travis.yml +15 -2
  7. data/Appraisals +1 -1
  8. data/CHANGELOG.md +31 -0
  9. data/Guardfile +8 -8
  10. data/README.md +256 -0
  11. data/Rakefile +2 -4
  12. data/active_data.gemspec +8 -7
  13. data/gemfiles/rails.4.0.gemfile +1 -1
  14. data/gemfiles/rails.4.1.gemfile +1 -1
  15. data/gemfiles/rails.4.2.gemfile +1 -1
  16. data/gemfiles/rails.5.0.gemfile +1 -1
  17. data/gemfiles/rails.5.1.gemfile +14 -0
  18. data/lib/active_data/active_record/associations.rb +18 -13
  19. data/lib/active_data/active_record/nested_attributes.rb +8 -14
  20. data/lib/active_data/base.rb +13 -0
  21. data/lib/active_data/config.rb +4 -4
  22. data/lib/active_data/errors.rb +29 -13
  23. data/lib/active_data/extensions.rb +22 -21
  24. data/lib/active_data/model/associations/base.rb +22 -6
  25. data/lib/active_data/model/associations/embeds_any.rb +17 -0
  26. data/lib/active_data/model/associations/embeds_many.rb +29 -19
  27. data/lib/active_data/model/associations/embeds_one.rb +30 -26
  28. data/lib/active_data/model/associations/nested_attributes.rb +82 -50
  29. data/lib/active_data/model/associations/persistence_adapters/active_record/referenced_proxy.rb +31 -0
  30. data/lib/active_data/model/associations/persistence_adapters/active_record.rb +66 -0
  31. data/lib/active_data/model/associations/persistence_adapters/base.rb +53 -0
  32. data/lib/active_data/model/associations/references_any.rb +41 -0
  33. data/lib/active_data/model/associations/references_many.rb +51 -37
  34. data/lib/active_data/model/associations/references_one.rb +43 -41
  35. data/lib/active_data/model/associations/reflections/base.rb +19 -29
  36. data/lib/active_data/model/associations/reflections/embeds_any.rb +43 -0
  37. data/lib/active_data/model/associations/reflections/embeds_many.rb +3 -13
  38. data/lib/active_data/model/associations/reflections/embeds_one.rb +5 -37
  39. data/lib/active_data/model/associations/reflections/references_any.rb +62 -0
  40. data/lib/active_data/model/associations/reflections/references_many.rb +7 -7
  41. data/lib/active_data/model/associations/reflections/references_one.rb +9 -7
  42. data/lib/active_data/model/associations/reflections/singular.rb +35 -0
  43. data/lib/active_data/model/associations/validations.rb +2 -27
  44. data/lib/active_data/model/associations.rb +12 -10
  45. data/lib/active_data/model/attributes/attribute.rb +10 -10
  46. data/lib/active_data/model/attributes/base.rb +8 -7
  47. data/lib/active_data/model/attributes/localized.rb +4 -4
  48. data/lib/active_data/model/attributes/reference_many.rb +6 -8
  49. data/lib/active_data/model/attributes/reference_one.rb +17 -9
  50. data/lib/active_data/model/attributes/reflections/attribute.rb +2 -2
  51. data/lib/active_data/model/attributes/reflections/base.rb +8 -11
  52. data/lib/active_data/model/attributes/reflections/localized.rb +2 -2
  53. data/lib/active_data/model/attributes/reflections/reference_one.rb +11 -22
  54. data/lib/active_data/model/attributes/reflections/represents.rb +5 -6
  55. data/lib/active_data/model/attributes/represents.rb +6 -5
  56. data/lib/active_data/model/attributes.rb +33 -87
  57. data/lib/active_data/model/callbacks.rb +6 -7
  58. data/lib/active_data/model/conventions.rb +2 -0
  59. data/lib/active_data/model/dirty.rb +4 -4
  60. data/lib/active_data/model/lifecycle.rb +18 -20
  61. data/lib/active_data/model/localization.rb +5 -2
  62. data/lib/active_data/model/persistence.rb +2 -2
  63. data/lib/active_data/model/primary.rb +19 -14
  64. data/lib/active_data/model/representation.rb +81 -0
  65. data/lib/active_data/model/scopes.rb +22 -12
  66. data/lib/active_data/model/validations/associated.rb +3 -2
  67. data/lib/active_data/model/validations/nested.rb +6 -1
  68. data/lib/active_data/model/validations.rb +3 -3
  69. data/lib/active_data/model.rb +2 -1
  70. data/lib/active_data/undefined_class.rb +9 -0
  71. data/lib/active_data/version.rb +1 -1
  72. data/lib/active_data.rb +40 -17
  73. data/spec/lib/active_data/active_record/associations_spec.rb +107 -45
  74. data/spec/lib/active_data/active_record/nested_attributes_spec.rb +1 -2
  75. data/spec/lib/active_data/config_spec.rb +37 -15
  76. data/spec/lib/active_data/model/associations/embeds_many_spec.rb +475 -172
  77. data/spec/lib/active_data/model/associations/embeds_one_spec.rb +353 -96
  78. data/spec/lib/active_data/model/associations/nested_attributes_spec.rb +108 -12
  79. data/spec/lib/active_data/model/associations/persistence_adapters/active_record_spec.rb +58 -0
  80. data/spec/lib/active_data/model/associations/references_many_spec.rb +440 -64
  81. data/spec/lib/active_data/model/associations/references_one_spec.rb +347 -36
  82. data/spec/lib/active_data/model/associations/reflections/embeds_many_spec.rb +8 -7
  83. data/spec/lib/active_data/model/associations/reflections/embeds_one_spec.rb +7 -6
  84. data/spec/lib/active_data/model/associations/reflections/references_many_spec.rb +81 -33
  85. data/spec/lib/active_data/model/associations/reflections/references_one_spec.rb +116 -37
  86. data/spec/lib/active_data/model/associations/validations_spec.rb +27 -43
  87. data/spec/lib/active_data/model/associations_spec.rb +34 -25
  88. data/spec/lib/active_data/model/attributes/attribute_spec.rb +26 -23
  89. data/spec/lib/active_data/model/attributes/base_spec.rb +5 -6
  90. data/spec/lib/active_data/model/attributes/collection_spec.rb +7 -8
  91. data/spec/lib/active_data/model/attributes/dictionary_spec.rb +40 -33
  92. data/spec/lib/active_data/model/attributes/localized_spec.rb +27 -28
  93. data/spec/lib/active_data/model/attributes/reflections/attribute_spec.rb +6 -6
  94. data/spec/lib/active_data/model/attributes/represents_spec.rb +10 -78
  95. data/spec/lib/active_data/model/attributes_spec.rb +150 -45
  96. data/spec/lib/active_data/model/callbacks_spec.rb +69 -70
  97. data/spec/lib/active_data/model/conventions_spec.rb +0 -1
  98. data/spec/lib/active_data/model/dirty_spec.rb +22 -13
  99. data/spec/lib/active_data/model/lifecycle_spec.rb +49 -23
  100. data/spec/lib/active_data/model/persistence_spec.rb +5 -6
  101. data/spec/lib/active_data/model/representation_spec.rb +126 -0
  102. data/spec/lib/active_data/model/scopes_spec.rb +1 -3
  103. data/spec/lib/active_data/model/typecasting_spec.rb +6 -5
  104. data/spec/lib/active_data/model/validations/associated_spec.rb +26 -18
  105. data/spec/lib/active_data/model/validations/nested_spec.rb +89 -18
  106. data/spec/lib/active_data/model_spec.rb +1 -2
  107. data/spec/lib/active_data_spec.rb +0 -1
  108. data/spec/shared/nested_attribute_examples.rb +332 -0
  109. data/spec/spec_helper.rb +3 -0
  110. data/spec/support/model_helpers.rb +2 -2
  111. data/spec/support/muffle_helper.rb +7 -0
  112. metadata +52 -18
  113. data/lib/active_data/model/associations/collection/referenced.rb +0 -26
  114. data/lib/active_data/model/associations/reflections/reference_reflection.rb +0 -45
  115. data/spec/lib/active_data/model/nested_attributes.rb +0 -202
@@ -0,0 +1,332 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'nested attributes' do
4
+ before do
5
+ stub_model :project do
6
+ include ActiveData::Model::Primary
7
+ include ActiveData::Model::Lifecycle
8
+
9
+ primary :slug, String
10
+ attribute :title, String
11
+ end
12
+
13
+ stub_model :profile do
14
+ include ActiveData::Model::Primary
15
+ include ActiveData::Model::Lifecycle
16
+
17
+ primary :identifier
18
+ attribute :first_name, String
19
+ end
20
+ end
21
+
22
+ context 'embeds_one' do
23
+ let(:user) { User.new }
24
+
25
+ specify { expect { user.profile_attributes = {} }.to change { user.profile }.to(an_instance_of(Profile)) }
26
+ specify { expect { user.profile_attributes = {first_name: 'User'} }.to change { user.profile.try(:first_name) }.to('User') }
27
+ specify { expect { user.profile_attributes = {identifier: 42, first_name: 'User'} }.to raise_error ActiveData::ObjectNotFound }
28
+
29
+ context ':reject_if' do
30
+ context do
31
+ before { User.accepts_nested_attributes_for :profile, reject_if: :all_blank }
32
+ specify { expect { user.profile_attributes = {first_name: ''} }.not_to change { user.profile } }
33
+ end
34
+
35
+ context do
36
+ before { User.accepts_nested_attributes_for :profile, reject_if: ->(attributes) { attributes['first_name'].blank? } }
37
+ specify { expect { user.profile_attributes = {first_name: ''} }.not_to change { user.profile } }
38
+ end
39
+ end
40
+
41
+ context 'existing' do
42
+ let(:profile) { Profile.new(first_name: 'User') }
43
+ let(:user) { User.new profile: profile }
44
+
45
+ specify { expect { user.profile_attributes = {identifier: 42, first_name: 'User'} }.to raise_error ActiveData::ObjectNotFound }
46
+ specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1'} }.to change { user.profile.first_name }.to('User 1') }
47
+ specify { expect { user.profile_attributes = {first_name: 'User 1'} }.to change { user.profile.first_name }.to('User 1') }
48
+ specify { expect { user.profile_attributes = {first_name: 'User 1', _destroy: '1'} }.not_to change { user.profile.first_name } }
49
+ specify do
50
+ expect do
51
+ user.profile_attributes = {first_name: 'User 1', _destroy: '1'}
52
+ user.save { true }
53
+ end.not_to change { user.profile.first_name }
54
+ end
55
+ specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'} }.to change { user.profile.first_name }.to('User 1') }
56
+ specify do
57
+ expect do
58
+ user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'}
59
+ user.save { true }
60
+ end.to change { user.profile.first_name }.to('User 1')
61
+ end
62
+
63
+ context ':allow_destroy' do
64
+ before { User.accepts_nested_attributes_for :profile, allow_destroy: true }
65
+
66
+ specify { expect { user.profile_attributes = {first_name: 'User 1', _destroy: '1'} }.not_to change { user.profile.first_name } }
67
+ specify do
68
+ expect do
69
+ user.profile_attributes = {first_name: 'User 1', _destroy: '1'}
70
+ user.save { true }
71
+ end.not_to change { user.profile.first_name }
72
+ end
73
+ specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'} }.to change { user.profile.first_name }.to('User 1') }
74
+ specify do
75
+ expect do
76
+ user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'}
77
+ user.save { true }
78
+ end.to change { user.profile }.to(nil)
79
+ end
80
+ end
81
+
82
+ context ':update_only' do
83
+ before { User.accepts_nested_attributes_for :profile, update_only: true }
84
+
85
+ specify do
86
+ expect { user.profile_attributes = {identifier: 42, first_name: 'User 1'} }
87
+ .to change { user.profile.first_name }.to('User 1')
88
+ end
89
+ end
90
+ end
91
+
92
+ context 'not primary' do
93
+ before do
94
+ stub_model :profile do
95
+ include ActiveData::Model::Lifecycle
96
+
97
+ attribute :identifier, Integer
98
+ attribute :first_name, String
99
+ end
100
+ end
101
+
102
+ specify { expect { user.profile_attributes = {} }.to change { user.profile }.to(an_instance_of(Profile)) }
103
+ specify { expect { user.profile_attributes = {first_name: 'User'} }.to change { user.profile.try(:first_name) }.to('User') }
104
+
105
+ context do
106
+ let(:profile) { Profile.new(first_name: 'User') }
107
+ let(:user) { User.new profile: profile }
108
+
109
+ specify do
110
+ expect { user.profile_attributes = {identifier: 42, first_name: 'User 1'} }
111
+ .to change { user.profile.first_name }.to('User 1')
112
+ end
113
+ end
114
+ end
115
+
116
+ context 'generated method overwrites' do
117
+ before do
118
+ User.class_eval <<-RUBY, __FILE__, __LINE__ + 1
119
+ def profile_attributes=(args)
120
+ args.reverse_merge!(first_name: 'Default Profile Name')
121
+ super
122
+ end
123
+ RUBY
124
+ end
125
+
126
+ it 'allows generated method overwritting' do
127
+ expect { user.profile_attributes = {} }
128
+ .to change { user.profile.try(:first_name) }.to('Default Profile Name')
129
+ end
130
+ end
131
+ end
132
+
133
+ context 'embeds_many' do
134
+ let(:user) { User.new }
135
+
136
+ specify { expect { user.projects_attributes = {} }.not_to change { user.projects } }
137
+ specify do
138
+ expect { user.projects_attributes = [{title: 'Project 1'}, {title: 'Project 2'}] }
139
+ .to change { user.projects.map(&:title) }.to(['Project 1', 'Project 2'])
140
+ end
141
+ specify do
142
+ expect { user.projects_attributes = {1 => {title: 'Project 1'}, 2 => {title: 'Project 2'}} }
143
+ .to change { user.projects.map(&:title) }.to(['Project 1', 'Project 2'])
144
+ end
145
+ specify do
146
+ expect { user.projects_attributes = [{slug: 42, title: 'Project 1'}, {title: 'Project 2'}] }
147
+ .to change { user.projects.map(&:title) }.to(['Project 1', 'Project 2'])
148
+ end
149
+ specify do
150
+ expect { user.projects_attributes = [{title: ''}, {title: 'Project 2'}] }
151
+ .to change { user.projects.map(&:title) }.to(['', 'Project 2'])
152
+ end
153
+
154
+ context ':limit' do
155
+ before { User.accepts_nested_attributes_for :projects, limit: 1 }
156
+
157
+ specify do
158
+ expect { user.projects_attributes = [{title: 'Project 1'}] }
159
+ .to change { user.projects.map(&:title) }.to(['Project 1'])
160
+ end
161
+ specify do
162
+ expect { user.projects_attributes = [{title: 'Project 1'}, {title: 'Project 2'}] }
163
+ .to raise_error ActiveData::TooManyObjects
164
+ end
165
+ end
166
+
167
+ context ':reject_if' do
168
+ context do
169
+ before { User.accepts_nested_attributes_for :projects, reject_if: :all_blank }
170
+ specify do
171
+ expect { user.projects_attributes = [{title: ''}, {title: 'Project 2'}] }
172
+ .to change { user.projects.map(&:title) }.to(['Project 2'])
173
+ end
174
+ end
175
+
176
+ context do
177
+ before { User.accepts_nested_attributes_for :projects, reject_if: ->(attributes) { attributes['title'].blank? } }
178
+ specify do
179
+ expect { user.projects_attributes = [{title: ''}, {title: 'Project 2'}] }
180
+ .to change { user.projects.map(&:title) }.to(['Project 2'])
181
+ end
182
+ end
183
+
184
+ context do
185
+ before { User.accepts_nested_attributes_for :projects, reject_if: ->(attributes) { attributes['foobar'].blank? } }
186
+ specify do
187
+ expect { user.projects_attributes = [{title: ''}, {title: 'Project 2'}] }
188
+ .not_to change { user.projects }
189
+ end
190
+ end
191
+ end
192
+
193
+ context 'existing' do
194
+ let(:projects) { Array.new(2) { |i| Project.new(title: "Project #{i.next}").tap { |pr| pr.slug = 42 + i } } }
195
+ let(:user) { User.new projects: projects }
196
+
197
+ specify do
198
+ expect do
199
+ user.projects_attributes = [
200
+ {slug: projects.first.slug.to_i, title: 'Project 3'},
201
+ {title: 'Project 4'}
202
+ ]
203
+ end
204
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2', 'Project 4'])
205
+ end
206
+ specify do
207
+ expect do
208
+ user.projects_attributes = [
209
+ {slug: projects.first.slug.to_i, title: 'Project 3'},
210
+ {slug: 33, title: 'Project 4'}
211
+ ]
212
+ end
213
+ .to change { user.projects.map(&:slug) }.to(%w[42 43 33])
214
+ end
215
+ specify do
216
+ expect do
217
+ user.projects_attributes = [
218
+ {slug: projects.first.slug.to_i, title: 'Project 3'},
219
+ {slug: 33, title: 'Project 4', _destroy: 1}
220
+ ]
221
+ end
222
+ .not_to change { user.projects.map(&:slug) }
223
+ end
224
+ specify do
225
+ expect do
226
+ user.projects_attributes = {
227
+ 1 => {slug: projects.first.slug.to_i, title: 'Project 3'},
228
+ 2 => {title: 'Project 4'}
229
+ }
230
+ end
231
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2', 'Project 4'])
232
+ end
233
+ specify do
234
+ expect do
235
+ user.projects_attributes = [
236
+ {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
237
+ {title: 'Project 4', _destroy: '1'}
238
+ ]
239
+ end
240
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
241
+ end
242
+ specify do
243
+ expect do
244
+ user.projects_attributes = [
245
+ {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
246
+ {title: 'Project 4', _destroy: '1'}
247
+ ]
248
+ user.save { true }
249
+ end
250
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
251
+ end
252
+
253
+ context ':allow_destroy' do
254
+ before { User.accepts_nested_attributes_for :projects, allow_destroy: true }
255
+
256
+ specify do
257
+ expect do
258
+ user.projects_attributes = [
259
+ {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
260
+ {title: 'Project 4', _destroy: '1'}
261
+ ]
262
+ end
263
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
264
+ end
265
+ specify do
266
+ expect do
267
+ user.projects_attributes = [
268
+ {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
269
+ {title: 'Project 4', _destroy: '1'}
270
+ ]
271
+ user.save { true }
272
+ end
273
+ .to change { user.projects.map(&:title) }.to(['Project 2'])
274
+ end
275
+ end
276
+
277
+ context ':update_only' do
278
+ before { User.accepts_nested_attributes_for :projects, update_only: true }
279
+
280
+ specify do
281
+ expect do
282
+ user.projects_attributes = [
283
+ {slug: projects.first.slug.to_i, title: 'Project 3'},
284
+ {title: 'Project 4'}
285
+ ]
286
+ end
287
+ .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
288
+ end
289
+
290
+ specify do
291
+ expect do
292
+ user.projects_attributes = [
293
+ {slug: projects.last.slug.to_i, title: 'Project 3'},
294
+ {slug: projects.first.slug.to_i.pred, title: 'Project 0'}
295
+ ]
296
+ end
297
+ .to change { user.projects.map(&:title) }.to(['Project 1', 'Project 3'])
298
+ end
299
+ end
300
+ end
301
+
302
+ context 'primary absence causes exception' do
303
+ before do
304
+ stub_model :project do
305
+ include ActiveData::Model::Primary
306
+ include ActiveData::Model::Lifecycle
307
+
308
+ attribute :slug, String
309
+ attribute :title, String
310
+ end
311
+ end
312
+
313
+ specify { expect { user.projects_attributes = {} }.to raise_error ActiveData::UndefinedPrimaryAttribute }
314
+ end
315
+
316
+ context 'generated method overwrites' do
317
+ before do
318
+ User.class_eval <<-RUBY, __FILE__, __LINE__ + 1
319
+ def projects_attributes=(args)
320
+ args << {title: 'Default Project'}
321
+ super
322
+ end
323
+ RUBY
324
+ end
325
+
326
+ it 'allows generated method overwritting' do
327
+ expect { user.projects_attributes = [] }
328
+ .to change { user.projects.map(&:title) }.to(['Default Project'])
329
+ end
330
+ end
331
+ end
332
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'bundler'
2
+ require 'pry'
2
3
  Bundler.require
3
4
 
4
5
  require 'rspec/its'
@@ -6,6 +7,7 @@ require 'active_record'
6
7
  require 'database_cleaner'
7
8
 
8
9
  require 'support/model_helpers'
10
+ require 'support/muffle_helper'
9
11
 
10
12
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
11
13
  ActiveRecord::Base.logger = Logger.new('/dev/null')
@@ -29,6 +31,7 @@ RSpec.configure do |config|
29
31
  config.filter_run focus: true
30
32
 
31
33
  config.include ModelHelpers
34
+ config.include MuffleHelpers
32
35
 
33
36
  config.before(:suite) do
34
37
  DatabaseCleaner.clean_with :truncation
@@ -1,9 +1,9 @@
1
1
  module ModelHelpers
2
- def stub_model name = nil, superclass = nil, &block
2
+ def stub_model(name = nil, superclass = nil, &block)
3
3
  stub_class(name, superclass) { include ActiveData::Model }.tap { |klass| klass.class_eval(&block) if block }
4
4
  end
5
5
 
6
- def stub_class name = nil, superclass = nil, &block
6
+ def stub_class(name = nil, superclass = nil, &block)
7
7
  klass = superclass ? Class.new(superclass, &block) : Class.new(&block)
8
8
  name.present? ? stub_const(name.to_s.camelize, klass) : klass
9
9
  end
@@ -0,0 +1,7 @@
1
+ module MuffleHelpers
2
+ def muffle(*exceptions)
3
+ yield
4
+ rescue *exceptions.flatten
5
+ nil
6
+ end
7
+ end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyromaniac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-03 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: appraisal
42
+ name: database_cleaner
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rspec-its
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: sqlite3
84
+ name: rspec-its
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: database_cleaner
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,19 +109,19 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: activerecord
112
+ name: sqlite3
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '4.0'
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '4.0'
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: uuidtools
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +137,7 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: activesupport
140
+ name: activemodel
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
@@ -137,7 +151,7 @@ dependencies:
137
151
  - !ruby/object:Gem::Version
138
152
  version: '4.0'
139
153
  - !ruby/object:Gem::Dependency
140
- name: activemodel
154
+ name: activesupport
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
@@ -171,11 +185,15 @@ executables: []
171
185
  extensions: []
172
186
  extra_rdoc_files: []
173
187
  files:
188
+ - ".codeclimate.yml"
174
189
  - ".gitignore"
175
190
  - ".rspec"
191
+ - ".rubocop.yml"
192
+ - ".rubocop_todo.yml"
176
193
  - ".rvmrc"
177
194
  - ".travis.yml"
178
195
  - Appraisals
196
+ - CHANGELOG.md
179
197
  - Gemfile
180
198
  - Guardfile
181
199
  - LICENSE
@@ -186,9 +204,11 @@ files:
186
204
  - gemfiles/rails.4.1.gemfile
187
205
  - gemfiles/rails.4.2.gemfile
188
206
  - gemfiles/rails.5.0.gemfile
207
+ - gemfiles/rails.5.1.gemfile
189
208
  - lib/active_data.rb
190
209
  - lib/active_data/active_record/associations.rb
191
210
  - lib/active_data/active_record/nested_attributes.rb
211
+ - lib/active_data/base.rb
192
212
  - lib/active_data/config.rb
193
213
  - lib/active_data/errors.rb
194
214
  - lib/active_data/extensions.rb
@@ -197,18 +217,24 @@ files:
197
217
  - lib/active_data/model/associations/base.rb
198
218
  - lib/active_data/model/associations/collection/embedded.rb
199
219
  - lib/active_data/model/associations/collection/proxy.rb
200
- - lib/active_data/model/associations/collection/referenced.rb
220
+ - lib/active_data/model/associations/embeds_any.rb
201
221
  - lib/active_data/model/associations/embeds_many.rb
202
222
  - lib/active_data/model/associations/embeds_one.rb
203
223
  - lib/active_data/model/associations/nested_attributes.rb
224
+ - lib/active_data/model/associations/persistence_adapters/active_record.rb
225
+ - lib/active_data/model/associations/persistence_adapters/active_record/referenced_proxy.rb
226
+ - lib/active_data/model/associations/persistence_adapters/base.rb
227
+ - lib/active_data/model/associations/references_any.rb
204
228
  - lib/active_data/model/associations/references_many.rb
205
229
  - lib/active_data/model/associations/references_one.rb
206
230
  - lib/active_data/model/associations/reflections/base.rb
231
+ - lib/active_data/model/associations/reflections/embeds_any.rb
207
232
  - lib/active_data/model/associations/reflections/embeds_many.rb
208
233
  - lib/active_data/model/associations/reflections/embeds_one.rb
209
- - lib/active_data/model/associations/reflections/reference_reflection.rb
234
+ - lib/active_data/model/associations/reflections/references_any.rb
210
235
  - lib/active_data/model/associations/reflections/references_many.rb
211
236
  - lib/active_data/model/associations/reflections/references_one.rb
237
+ - lib/active_data/model/associations/reflections/singular.rb
212
238
  - lib/active_data/model/associations/validations.rb
213
239
  - lib/active_data/model/attributes.rb
214
240
  - lib/active_data/model/attributes/attribute.rb
@@ -234,11 +260,13 @@ files:
234
260
  - lib/active_data/model/localization.rb
235
261
  - lib/active_data/model/persistence.rb
236
262
  - lib/active_data/model/primary.rb
263
+ - lib/active_data/model/representation.rb
237
264
  - lib/active_data/model/scopes.rb
238
265
  - lib/active_data/model/validations.rb
239
266
  - lib/active_data/model/validations/associated.rb
240
267
  - lib/active_data/model/validations/nested.rb
241
268
  - lib/active_data/railtie.rb
269
+ - lib/active_data/undefined_class.rb
242
270
  - lib/active_data/version.rb
243
271
  - spec/lib/active_data/active_record/associations_spec.rb
244
272
  - spec/lib/active_data/active_record/nested_attributes_spec.rb
@@ -246,6 +274,7 @@ files:
246
274
  - spec/lib/active_data/model/associations/embeds_many_spec.rb
247
275
  - spec/lib/active_data/model/associations/embeds_one_spec.rb
248
276
  - spec/lib/active_data/model/associations/nested_attributes_spec.rb
277
+ - spec/lib/active_data/model/associations/persistence_adapters/active_record_spec.rb
249
278
  - spec/lib/active_data/model/associations/references_many_spec.rb
250
279
  - spec/lib/active_data/model/associations/references_one_spec.rb
251
280
  - spec/lib/active_data/model/associations/reflections/embeds_many_spec.rb
@@ -271,9 +300,9 @@ files:
271
300
  - spec/lib/active_data/model/conventions_spec.rb
272
301
  - spec/lib/active_data/model/dirty_spec.rb
273
302
  - spec/lib/active_data/model/lifecycle_spec.rb
274
- - spec/lib/active_data/model/nested_attributes.rb
275
303
  - spec/lib/active_data/model/persistence_spec.rb
276
304
  - spec/lib/active_data/model/primary_spec.rb
305
+ - spec/lib/active_data/model/representation_spec.rb
277
306
  - spec/lib/active_data/model/scopes_spec.rb
278
307
  - spec/lib/active_data/model/typecasting_spec.rb
279
308
  - spec/lib/active_data/model/validations/associated_spec.rb
@@ -281,8 +310,10 @@ files:
281
310
  - spec/lib/active_data/model/validations_spec.rb
282
311
  - spec/lib/active_data/model_spec.rb
283
312
  - spec/lib/active_data_spec.rb
313
+ - spec/shared/nested_attribute_examples.rb
284
314
  - spec/spec_helper.rb
285
315
  - spec/support/model_helpers.rb
316
+ - spec/support/muffle_helper.rb
286
317
  homepage: ''
287
318
  licenses: []
288
319
  metadata: {}
@@ -302,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
333
  version: '0'
303
334
  requirements: []
304
335
  rubyforge_project:
305
- rubygems_version: 2.5.1
336
+ rubygems_version: 2.7.4
306
337
  signing_key:
307
338
  specification_version: 4
308
339
  summary: Working with hashes in AR style
@@ -313,6 +344,7 @@ test_files:
313
344
  - spec/lib/active_data/model/associations/embeds_many_spec.rb
314
345
  - spec/lib/active_data/model/associations/embeds_one_spec.rb
315
346
  - spec/lib/active_data/model/associations/nested_attributes_spec.rb
347
+ - spec/lib/active_data/model/associations/persistence_adapters/active_record_spec.rb
316
348
  - spec/lib/active_data/model/associations/references_many_spec.rb
317
349
  - spec/lib/active_data/model/associations/references_one_spec.rb
318
350
  - spec/lib/active_data/model/associations/reflections/embeds_many_spec.rb
@@ -338,9 +370,9 @@ test_files:
338
370
  - spec/lib/active_data/model/conventions_spec.rb
339
371
  - spec/lib/active_data/model/dirty_spec.rb
340
372
  - spec/lib/active_data/model/lifecycle_spec.rb
341
- - spec/lib/active_data/model/nested_attributes.rb
342
373
  - spec/lib/active_data/model/persistence_spec.rb
343
374
  - spec/lib/active_data/model/primary_spec.rb
375
+ - spec/lib/active_data/model/representation_spec.rb
344
376
  - spec/lib/active_data/model/scopes_spec.rb
345
377
  - spec/lib/active_data/model/typecasting_spec.rb
346
378
  - spec/lib/active_data/model/validations/associated_spec.rb
@@ -348,5 +380,7 @@ test_files:
348
380
  - spec/lib/active_data/model/validations_spec.rb
349
381
  - spec/lib/active_data/model_spec.rb
350
382
  - spec/lib/active_data_spec.rb
383
+ - spec/shared/nested_attribute_examples.rb
351
384
  - spec/spec_helper.rb
352
385
  - spec/support/model_helpers.rb
386
+ - spec/support/muffle_helper.rb
@@ -1,26 +0,0 @@
1
- module ActiveData
2
- module Model
3
- module Associations
4
- module Collection
5
- class Referenced < Proxy
6
- METHODS_EXCLUDED_FROM_DELEGATION = %w[build create create!].map(&:to_sym).freeze
7
- delegate :scope, to: :@association
8
-
9
- def method_missing(method, *args, &block)
10
- delegate_to_scope?(method) ? scope.send(method, *args, &block) : super
11
- end
12
-
13
- def respond_to_missing?(method, include_private = false)
14
- delegate_to_scope?(method) || super
15
- end
16
-
17
- private
18
-
19
- def delegate_to_scope?(method)
20
- METHODS_EXCLUDED_FROM_DELEGATION.exclude?(method) && scope.respond_to?(method)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end