active_interaction 1.2.3 → 1.3.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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +277 -72
  3. data/README.md +4 -4
  4. data/lib/active_interaction/backports.rb +6 -1
  5. data/lib/active_interaction/base.rb +15 -7
  6. data/lib/active_interaction/concerns/transactable.rb +7 -0
  7. data/lib/active_interaction/errors.rb +3 -3
  8. data/lib/active_interaction/filters/abstract_filter.rb +1 -1
  9. data/lib/active_interaction/filters/array_filter.rb +2 -0
  10. data/lib/active_interaction/filters/decimal_filter.rb +3 -1
  11. data/lib/active_interaction/filters/interface_filter.rb +44 -0
  12. data/lib/active_interaction/filters/model_filter.rb +2 -2
  13. data/lib/active_interaction/filters/time_filter.rb +8 -0
  14. data/lib/active_interaction/locale/en.yml +1 -0
  15. data/lib/active_interaction/version.rb +1 -1
  16. data/lib/active_interaction.rb +2 -2
  17. data/spec/active_interaction/base_spec.rb +91 -30
  18. data/spec/active_interaction/concerns/missable_spec.rb +2 -2
  19. data/spec/active_interaction/concerns/runnable_spec.rb +5 -2
  20. data/spec/active_interaction/concerns/transactable_spec.rb +24 -3
  21. data/spec/active_interaction/errors_spec.rb +1 -1
  22. data/spec/active_interaction/filter_column_spec.rb +5 -5
  23. data/spec/active_interaction/filters/boolean_filter_spec.rb +2 -2
  24. data/spec/active_interaction/filters/interface_filter_spec.rb +46 -0
  25. data/spec/active_interaction/filters/model_filter_spec.rb +11 -0
  26. data/spec/active_interaction/filters/time_filter_spec.rb +20 -0
  27. data/spec/active_interaction/i18n_spec.rb +6 -0
  28. data/spec/active_interaction/integration/interface_interaction_spec.rb +12 -0
  29. data/spec/active_interaction/integration/model_interaction_spec.rb +1 -1
  30. data/spec/active_interaction/modules/input_processor_spec.rb +2 -2
  31. data/spec/active_interaction/modules/validation_spec.rb +2 -2
  32. data/spec/spec_helper.rb +6 -3
  33. metadata +51 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ba88eafd8b605090eafd610e1b9b4e41638e5b8
4
- data.tar.gz: 44de977111bd36c6348864c0024ff886d71022c5
3
+ metadata.gz: 20cc4b1b768b7f7dddca393b9554a664bb23010a
4
+ data.tar.gz: c746e003137672689025a54a9245330527088366
5
5
  SHA512:
6
- metadata.gz: 1befd803a782dfe60b5c058f49b3e670e2f4b8d4d5434b15e81acdb7564ab803812dcce8172c615fe0bc04f7a8be7576615f02b9183d8d3a9c8776f77f2c6a92
7
- data.tar.gz: ced6bb16015b351c6d4555feb91d84f82ed4e62f3cb9ca650c9ac7c3be9d2f7edcf29f94a84aef6e24fe58572b41de52565bf4c436d3db534e48758cfc39f286
6
+ metadata.gz: 678d8066fa76930180a241ab069617a46d083ac2ca558a4cfee8cb4e6a76131e907ed486ddbd898be89d4f513c74a5799169ba556d24240deb9ad005748c7bcd
7
+ data.tar.gz: ac3d346048c4744d9b2ca25f91b2f719d0b3fcec609671feaf94353e00d4717c147c6e9b47a669cf37d39d327b8c9352e4ac6f9f78cd8d3106235c44e5ede6d2
data/CHANGELOG.md CHANGED
@@ -1,216 +1,355 @@
1
1
  # [Master][]
2
2
 
3
+ # [1.3.0][] (2014-08-15)
4
+
5
+ ## Added
6
+
7
+ - [#178][]: Add an interface filter.
8
+ - [#196][]: Add a `type_check` callback that happens before the `validation`
9
+ callback.
10
+
11
+ # [1.2.5][] (2014-08-15)
12
+
13
+ ## Fixed
14
+
15
+ - [#207][]: Fix a bug that incorrectly converted plural class names
16
+ to their singular form.
17
+ - [#206][]: Fix a bug that caused an i18n deprecation warning.
18
+ - [#201][]: Prevented time filters from being initialized with the
19
+ format option when time zones are available.
20
+
21
+ # [1.2.4][] (2014-08-07)
22
+
23
+ ## Fixed
24
+
25
+ - [#203][]: Fix a bug that prevented transaction options from being passed to
26
+ subclasses.
27
+
3
28
  # [1.2.3][] (2014-05-12)
4
29
 
5
- - Fix a bug that raised `ActiveRecord::Rollback` when composing even when not
6
- in a transaction.
30
+ ## Fixed
31
+
32
+ - [#192][]: Fix a bug that raised `ActiveRecord::Rollback` when composing even
33
+ when not in a transaction.
7
34
 
8
35
  # [1.2.2][] (2014-05-07)
9
36
 
37
+ ## Fixed
38
+
10
39
  - Fix a bug that raised `NameError`s when there were invalid nested hash
11
40
  errors.
12
41
  - Add missing translation for symbol filters.
13
42
 
14
43
  # [1.2.1][] (2014-05-02)
15
44
 
16
- - Fix a bug that marked model inputs as invalid even if they returned true for
17
- `object.is_a?(klass)`.
45
+ ## Fixed
46
+
47
+ - [#179][]: Fix a bug that marked model inputs as invalid even if they returned true
48
+ for `object.is_a?(klass)`.
18
49
 
19
50
  # [1.2.0][] (2014-04-30)
20
51
 
21
- - Add support for Rails-style date and time parameters like `date(1i)`.
22
- - Add a decimal filter.
23
- - Add support for disabling and modifying transactions through the
52
+ ## Added
53
+
54
+ - [#175][]: Add support for Rails-style date and time parameters like `date(1i)`.
55
+ - [#173][]: Add a decimal filter.
56
+ - [#155][]: Add support for disabling and modifying transactions through the
24
57
  `transaction` helper method.
25
- - Add support for `column_for_attribute` which provides better interoperability with gems like Formtastic and Simple Form.
58
+ - [#140][]: Add support for `column_for_attribute` which provides better
59
+ interoperability with gems like Formtastic and Simple Form.
26
60
 
27
61
  # [1.1.7][] (2014-04-30)
28
62
 
29
- - Fix a bug that leaked validators among all child classes.
63
+ ## Fixed
64
+
65
+ - [#174][]: Fix a bug that leaked validators among all child classes.
30
66
 
31
67
  # [1.1.6][] (2014-04-29)
32
68
 
33
- - Fix a bug that caused nested hash error messages to be misleading.
69
+ ## Fixed
70
+
71
+ - [#36][]: Fix a bug that caused nested hash error messages to be misleading.
34
72
 
35
73
  # [1.1.5][] (2014-03-31)
36
74
 
37
- - The `transform_keys` method broke backwards compatibility because it's not available until Rails 4.0.2.
75
+ ## Fixed
76
+
77
+ - The `transform_keys` method broke backwards compatibility because it's not
78
+ available until Rails 4.0.2.
38
79
 
39
80
  # [1.1.4][] (2014-03-31)
40
81
 
82
+ ## Fixed
83
+
41
84
  - Fix an issue where non-stripped hash keys would be incorrectly converted to strings.
42
85
 
43
86
  # [1.1.3][] (2014-03-31)
44
87
 
45
- - Fix Rubocop errors and pin the version to avoid future issues with new cops
88
+ ## Fixed
89
+
90
+ - [#165][]: Fix Rubocop errors and pin the version to avoid future issues with new cops
46
91
  breaking the build.
47
- - Fix some denial of service attacks via hash symbolization. (See [#163][] for details)
92
+
93
+ ## Security
94
+
95
+ - [#163][]: Fix some denial of service attacks via hash symbolization.
48
96
 
49
97
  # [1.1.2][] (2014-03-05)
50
98
 
51
- - Don't constantize classes for model filters on initialization. This fixes a
99
+ ## Fixed
100
+
101
+ - [#156][]: Don't constantize classes for model filters on initialization. This fixes a
52
102
  bug that made those filters dependent on load order.
53
103
 
54
104
  # [1.1.1][] (2014-03-04)
55
105
 
56
- - Allow merging ActiveModel errors into ActiveInteraction errors with
106
+ ## Fixed
107
+
108
+ - [#153][]: Allow merging ActiveModel errors into ActiveInteraction errors with
57
109
  `ActiveInteraction::Errors#merge!`.
58
110
 
59
111
  # [1.1.0][] (2014-02-28)
60
112
 
61
- - Only set instance variables for attributes with readers defined.
62
- - Support `:only` and `:except` options simultaneously with `import_filters`.
113
+ ## Added
114
+
115
+ - [#116][], [#119][], [#122][]: Speed up many filters by caching class constants.
116
+ - [#115][]: Add support for callbacks around `execute`.
117
+ - [#136][]: Allow callable defaults.
118
+
119
+ ## Changed
120
+
121
+ - [#114][]: Support `:only` and `:except` options simultaneously with `import_filters`.
63
122
  Previously this raised an `ArgumentError`.
64
- - Support passing a single symbol to `:only` and `:except`. Previously an Array
123
+ - [#114][]: Support passing a single symbol to `:only` and `:except`. Previously an Array
65
124
  was required.
66
- - Speed up many filters by caching class constants.
67
- - Add support for callbacks around `execute`.
68
- - Allow callable defaults.
125
+
126
+ ## Security
127
+
128
+ - [#138][]: Only set instance variables for attributes with readers defined.
129
+
69
130
 
70
131
  # [1.0.5][] (2014-02-25)
71
132
 
72
- - Rollback database changes when `compose` fails.
133
+ ## Fixed
134
+
135
+ - [#143][]: Rollback database changes when `compose` fails.
73
136
 
74
137
  # [1.0.4][] (2014-02-11)
75
138
 
139
+ ## Fixed
140
+
76
141
  - Add translations to the gem specification.
77
142
 
78
143
  # ~~[1.0.3][] (2014-02-11)~~
79
144
 
80
- - Fix a bug that caused invalid strings to be parsed as `nil` instead of
145
+ ## Fixed
146
+
147
+ - [#135][]: Fix a bug that caused invalid strings to be parsed as `nil` instead of
81
148
  raising an error when `Time.zone` was set.
82
- - Fix bug that prevented loading I18n translations.
149
+ - [#134][]: Fix bug that prevented loading I18n translations.
83
150
 
84
151
  # [1.0.2][] (2014-02-07)
85
152
 
86
- - Stop creating duplicate errors on subsequent calls to `valid?`.
153
+ ## Fixed
154
+
155
+ - [#130][]: Stop creating duplicate errors on subsequent calls to `valid?`.
87
156
 
88
157
  # [1.0.1][] (2014-02-04)
89
158
 
90
- - Short circuit `valid?` after successfully running an interaction.
91
- - Fix a bug that prevented merging interpolated symbolic errors.
92
- - Use `:invalid_type` instead of `:invalid` as I18n key for type errors.
93
- - Fix a bug that skipped setting up accessors for imported filters.
159
+ ## Fixed
160
+
161
+ - [#125][]: Short circuit `valid?` after successfully running an interaction.
162
+ - [#129][]: Fix a bug that prevented merging interpolated symbolic errors.
163
+ - [#128][]: Use `:invalid_type` instead of `:invalid` as I18n key for type errors.
164
+ - [#127][]: Fix a bug that skipped setting up accessors for imported filters.
94
165
 
95
166
  # [1.0.0][] (2014-01-21)
96
167
 
97
- - **Replace `Filters` with a hash.** To iterate over `Filter` objects, use
168
+ ## Added
169
+
170
+ - [#102][]: Add predicate methods for checking if an input was passed.
171
+ - [#103][]: Allow fetching filters by name.
172
+ - [#104][]: Allow import filters from another interaction with `import_filters`.
173
+
174
+ ## Changed
175
+
176
+ - [#111][]: Replace `Filters` with a hash. To iterate over `Filter` objects, use
98
177
  `Interaction.filters.values`.
99
178
  - Rename `Filter#has_default?` to `Filter#default?`.
100
- - Add `respond_to_missing?` to complement `method_missing` calls.
101
- - Add predicate methods for checking if an input was passed.
102
- - When adding a filter that shares a name with an existing filter, it will now
179
+
180
+ ## Fixed
181
+
182
+ - [#98][]: Add `respond_to_missing?` to complement `method_missing` calls.
183
+ - [#106][]: When adding a filter that shares a name with an existing filter, it will now
103
184
  replace the existing one instead of adding a duplicate.
104
- - Allow fetching filters by name.
105
- - Allow import filters from another interaction with `import_filters`.
106
185
 
107
186
  # [0.10.2][] (2014-01-02)
108
187
 
109
- - Fix a bug that marked Time instances as invalid if Time.zone was set.
188
+ ## Fixed
189
+
190
+ - [#94][]: Fix a bug that marked Time instances as invalid if Time.zone was set.
110
191
 
111
192
  # [0.10.1][] (2013-12-20)
112
193
 
113
- - Fix bug that prevented parsing strings as times when ActiveSupport was
194
+ ## Fixed
195
+
196
+ - [#90][]: Fix bug that prevented parsing strings as times when ActiveSupport was
114
197
  available.
115
198
 
116
199
  # [0.10.0][] (2013-12-19)
117
200
 
201
+ ## Added
202
+
118
203
  - Support casting "true" and "false" as booleans.
119
- - Fix bug that allowed subclasses to mutate the filters on their superclasses.
204
+
205
+ ## Fixed
206
+
207
+ - [#89][]: Fix bug that allowed subclasses to mutate the filters on their superclasses.
120
208
 
121
209
  # [0.9.1][] (2013-12-17)
122
210
 
123
- - Fix I18n deprecation warning.
124
- - Raise `ArgumentError` when running an interaction with non-hash inputs.
125
- - For compatibility with `ActiveRecord::Errors`, support indifferent access of
211
+ ## Fixed
212
+
213
+ - [#84][]: Fix I18n deprecation warning.
214
+ - [#82][]: Raise `ArgumentError` when running an interaction with non-hash inputs.
215
+ - [#77][]: For compatibility with `ActiveRecord::Errors`, support indifferent access of
126
216
  `ActiveInteraction::Errors`.
127
- - Fix losing filters when using inheritance.
217
+ - [#88][]: Fix losing filters when using inheritance.
128
218
 
129
219
  # [0.9.0][] (2013-12-02)
130
220
 
131
- - Add experimental composition implementation
132
- (`ActiveInteraction::Base#compose`).
221
+ ## Added
222
+
223
+ - Add experimental composition implementation (`ActiveInteraction::Base#compose`).
224
+
225
+ ## Removed
226
+
133
227
  - Remove `ActiveInteraction::Pipeline`.
134
228
 
135
229
  # [0.8.0][] (2013-11-14)
136
230
 
137
- - Add ability to document interactions and filters.
231
+ ## Added
232
+
233
+ - [#44][], [#45][]: Add ability to document interactions and filters.
138
234
 
139
235
  # [0.7.0][] (2013-11-14)
140
236
 
141
- - Add ability to chain a series of interactions together with
237
+ ## Added
238
+
239
+ - [#41][]: Add ability to chain a series of interactions together with
142
240
  `ActiveInteraction::Pipeline`.
143
241
 
144
242
  # [0.6.1][] (2013-11-14)
145
243
 
244
+ ## Fixed
245
+
146
246
  - Re-release. Forgot to merge into master.
147
247
 
148
248
  # ~~[0.6.0][] (2013-11-14)~~
149
249
 
150
- - **Error class now end with `Error`.**
151
- - **By default, strip unlisted keys from hashes. To retain the old behavior,
152
- set `strip: false` on a hash filter.**
153
- - **Prevent specifying defaults (other than `nil` or `{}`) on hash filters. Set
154
- defaults on the nested filters instead.**
250
+ ## Added
251
+
155
252
  - Add ability to introspect interactions with `filters`.
156
- - Fix bug that prevented listing multiple attributes in a hash filter.
157
- - Allow getting all of the user-supplied inputs in an interaction with
253
+ - [#57][]: Allow getting all of the user-supplied inputs in an interaction with
158
254
  `inputs`.
159
- - Fix bug that prevented hash filters from being nested in array filters.
160
- - Replace `allow_nil: true` with `default: nil`.
161
- - Add a symbol filter.
162
- - Allow adding symbolic errors with `errors.add_sym` and retrieving them with
255
+ - [#61][]: Add a symbol filter.
256
+ - [#58][]: Allow adding symbolic errors with `errors.add_sym` and retrieving them with
163
257
  `errors.symbolic`.
164
258
 
259
+ ## Changed
260
+
261
+ - Error class now end with `Error`.
262
+ - By default, strip unlisted keys from hashes. To retain the old behavior,
263
+ set `strip: false` on a hash filter.
264
+ - [#49][]: Prevent specifying defaults (other than `nil` or `{}`) on hash filters. Set
265
+ defaults on the nested filters instead.
266
+ - [#66][]: Replace `allow_nil: true` with `default: nil`.
267
+
268
+ ## Fixed
269
+
270
+ - Fix bug that prevented listing multiple attributes in a hash filter.
271
+ - Fix bug that prevented hash filters from being nested in array filters.
272
+
165
273
  # [0.5.0][] (2013-10-16)
166
274
 
167
- - Allow adding errors in `execute` method with `errors.add`.
168
- - Prevent manually setting the outcome's result.
275
+ ## Added
276
+
277
+ - [#34][]: Allow adding errors in `execute` method with `errors.add`.
278
+
279
+ ## Fixed
280
+
281
+ - [#56][]: Prevent manually setting the outcome's result.
169
282
 
170
283
  # [0.4.0][] (2013-08-15)
171
284
 
285
+ ## Added
286
+
172
287
  - Support i18n translations.
173
288
 
174
289
  # [0.3.0][] (2013-08-07)
175
290
 
176
- - Give better error messages for nested attributes.
177
- - Use default value when given an explicit `nil`.
178
- - Allow nested default values.
291
+ ## Added
292
+
293
+ - [#30][]: Allow nested default values.
294
+
295
+ ## Changed
296
+
297
+ - [#36][]: Give better error messages for nested attributes.
298
+ - [#39][]: Add a more useful invalid interaction error message.
299
+ - [#38][]: Use default value when given an explicit `nil`.
179
300
 
180
301
  # [0.2.2][] (2013-08-07)
181
302
 
182
- - Fix support for `ActiveSupport::TimeWithZone`.
303
+ ## Fixed
304
+
305
+ - [#40][]: Fix support for `ActiveSupport::TimeWithZone`.
183
306
 
184
307
  # [0.2.1][] (2013-08-06)
185
308
 
186
- - Fix setting a default value on more than one attribute at a time.
309
+ ## Fixed
310
+
311
+ - [#37][]: Fix setting a default value on more than one attribute at a time.
187
312
 
188
313
  # [0.2.0][] (2013-07-16)
189
314
 
190
- - Wrap interactions in ActiveRecord transactions if they're available.
191
- - Add option to strip string values, which is enabled by default.
192
- - Add support for strptime format strings on Date, DateTime, and Time filters.
315
+ ## Added
316
+
317
+ - [#23][]: Add support for strptime format strings on Date, DateTime, and Time filters.
318
+
319
+ ## Changed
320
+
321
+ - [#20][]: Wrap interactions in ActiveRecord transactions if they're available.
322
+ - [#24][]: Add option to strip string values, which is enabled by default.
193
323
 
194
324
  # [0.1.3][] (2013-07-16)
195
325
 
326
+ ## Fixed
327
+
196
328
  - Fix bug that prevented `attr_accessor`s from working.
197
329
  - Handle unconfigured timezones.
198
- - Use RDoc as YARD's Markdown provider instead of kramdown.
330
+ - [#27][]: Use RDoc as YARD's Markdown provider instead of kramdown.
199
331
 
200
332
  # [0.1.2][] (2013-07-14)
201
333
 
202
- - `execute` will now have the filtered version of the values passed
334
+ ## Fixed
335
+
336
+ - [#29][]: `execute` will now have the filtered version of the values passed
203
337
  to `run` or `run!` as was intended.
204
338
 
205
339
  # [0.1.1][] (2013-07-13)
206
340
 
207
- - Correct gemspec dependencies on activemodel.
341
+ ## Fixed
342
+
343
+ - [#28][]: Correct gemspec dependencies on activemodel.
208
344
 
209
345
  # ~~[0.1.0][] (2013-07-12)~~
210
346
 
211
347
  - Initial release.
212
348
 
213
- [master]: https://github.com/orgsync/active_interaction/compare/v1.2.3...master
349
+ [master]: https://github.com/orgsync/active_interaction/compare/v1.3.0...master
350
+ [1.3.0]: https://github.com/orgsync/active_interaction/compare/v1.2.5...v1.3.0
351
+ [1.2.5]: https://github.com/orgsync/active_interaction/compare/v1.2.4...v1.2.5
352
+ [1.2.4]: https://github.com/orgsync/active_interaction/compare/v1.2.3...v1.2.4
214
353
  [1.2.3]: https://github.com/orgsync/active_interaction/compare/v1.2.2...v1.2.3
215
354
  [1.2.2]: https://github.com/orgsync/active_interaction/compare/v1.2.1...v1.2.2
216
355
  [1.2.1]: https://github.com/orgsync/active_interaction/compare/v1.2.0...v1.2.1
@@ -249,4 +388,70 @@
249
388
  [0.1.1]: https://github.com/orgsync/active_interaction/compare/v0.1.0...v0.1.1
250
389
  [0.1.0]: https://github.com/orgsync/active_interaction/compare/62f999b...v0.1.0
251
390
 
252
- [#163]: https://github.com/orgsync/active_interaction/pull/163
391
+ [#20]: https://github.com/orgsync/active_interaction/issues/20
392
+ [#23]: https://github.com/orgsync/active_interaction/issues/23
393
+ [#24]: https://github.com/orgsync/active_interaction/issues/24
394
+ [#27]: https://github.com/orgsync/active_interaction/issues/27
395
+ [#28]: https://github.com/orgsync/active_interaction/issues/28
396
+ [#29]: https://github.com/orgsync/active_interaction/issues/29
397
+ [#30]: https://github.com/orgsync/active_interaction/issues/30
398
+ [#34]: https://github.com/orgsync/active_interaction/issues/34
399
+ [#36]: https://github.com/orgsync/active_interaction/issues/36
400
+ [#37]: https://github.com/orgsync/active_interaction/issues/37
401
+ [#38]: https://github.com/orgsync/active_interaction/issues/38
402
+ [#39]: https://github.com/orgsync/active_interaction/issues/39
403
+ [#40]: https://github.com/orgsync/active_interaction/issues/40
404
+ [#41]: https://github.com/orgsync/active_interaction/issues/41
405
+ [#44]: https://github.com/orgsync/active_interaction/issues/44
406
+ [#45]: https://github.com/orgsync/active_interaction/issues/45
407
+ [#49]: https://github.com/orgsync/active_interaction/issues/49
408
+ [#56]: https://github.com/orgsync/active_interaction/issues/56
409
+ [#57]: https://github.com/orgsync/active_interaction/issues/57
410
+ [#58]: https://github.com/orgsync/active_interaction/issues/58
411
+ [#61]: https://github.com/orgsync/active_interaction/issues/61
412
+ [#66]: https://github.com/orgsync/active_interaction/issues/66
413
+ [#77]: https://github.com/orgsync/active_interaction/issues/77
414
+ [#82]: https://github.com/orgsync/active_interaction/issues/82
415
+ [#84]: https://github.com/orgsync/active_interaction/issues/84
416
+ [#88]: https://github.com/orgsync/active_interaction/issues/88
417
+ [#89]: https://github.com/orgsync/active_interaction/issues/89
418
+ [#90]: https://github.com/orgsync/active_interaction/issues/90
419
+ [#94]: https://github.com/orgsync/active_interaction/issues/94
420
+ [#98]: https://github.com/orgsync/active_interaction/issues/98
421
+ [#102]: https://github.com/orgsync/active_interaction/issues/102
422
+ [#103]: https://github.com/orgsync/active_interaction/issues/103
423
+ [#104]: https://github.com/orgsync/active_interaction/issues/104
424
+ [#106]: https://github.com/orgsync/active_interaction/issues/106
425
+ [#111]: https://github.com/orgsync/active_interaction/issues/111
426
+ [#114]: https://github.com/orgsync/active_interaction/issues/114
427
+ [#115]: https://github.com/orgsync/active_interaction/issues/115
428
+ [#116]: https://github.com/orgsync/active_interaction/issues/116
429
+ [#119]: https://github.com/orgsync/active_interaction/issues/119
430
+ [#122]: https://github.com/orgsync/active_interaction/issues/122
431
+ [#125]: https://github.com/orgsync/active_interaction/issues/125
432
+ [#127]: https://github.com/orgsync/active_interaction/issues/127
433
+ [#128]: https://github.com/orgsync/active_interaction/issues/128
434
+ [#129]: https://github.com/orgsync/active_interaction/issues/129
435
+ [#130]: https://github.com/orgsync/active_interaction/issues/130
436
+ [#134]: https://github.com/orgsync/active_interaction/issues/134
437
+ [#135]: https://github.com/orgsync/active_interaction/issues/135
438
+ [#136]: https://github.com/orgsync/active_interaction/issues/136
439
+ [#138]: https://github.com/orgsync/active_interaction/issues/138
440
+ [#140]: https://github.com/orgsync/active_interaction/issues/140
441
+ [#143]: https://github.com/orgsync/active_interaction/issues/143
442
+ [#153]: https://github.com/orgsync/active_interaction/issues/153
443
+ [#155]: https://github.com/orgsync/active_interaction/issues/155
444
+ [#156]: https://github.com/orgsync/active_interaction/issues/156
445
+ [#163]: https://github.com/orgsync/active_interaction/issues/163
446
+ [#165]: https://github.com/orgsync/active_interaction/issues/165
447
+ [#173]: https://github.com/orgsync/active_interaction/issues/173
448
+ [#174]: https://github.com/orgsync/active_interaction/issues/174
449
+ [#175]: https://github.com/orgsync/active_interaction/issues/175
450
+ [#178]: https://github.com/orgsync/active_interaction/issues/178
451
+ [#179]: https://github.com/orgsync/active_interaction/issues/179
452
+ [#192]: https://github.com/orgsync/active_interaction/issues/192
453
+ [#196]: https://github.com/orgsync/active_interaction/issues/196
454
+ [#201]: https://github.com/orgsync/active_interaction/issues/201
455
+ [#203]: https://github.com/orgsync/active_interaction/issues/203
456
+ [#206]: https://github.com/orgsync/active_interaction/issues/206
457
+ [#207]: https://github.com/orgsync/active_interaction/issues/207
data/README.md CHANGED
@@ -25,7 +25,7 @@ This project uses [semantic versioning][13].
25
25
  Add it to your Gemfile:
26
26
 
27
27
  ```ruby
28
- gem 'active_interaction', '~> 1.2'
28
+ gem 'active_interaction', '~> 1.3'
29
29
  ```
30
30
 
31
31
  And then execute:
@@ -282,12 +282,12 @@ work done in [Mutations][17].
282
282
 
283
283
  [0]: https://github.com/orgsync/active_interaction
284
284
  [1]: https://badge.fury.io/rb/active_interaction.svg
285
- [2]: https://badge.fury.io/rb/active_interaction "Gem Version"
285
+ [2]: http://rubygems.org/gems/active_interaction "Gem Version"
286
286
  [3]: https://travis-ci.org/orgsync/active_interaction.svg?branch=master
287
287
  [4]: https://travis-ci.org/orgsync/active_interaction "Build Status"
288
- [5]: https://coveralls.io/repos/orgsync/active_interaction/badge.png?branch=master
288
+ [5]: https://img.shields.io/coveralls/orgsync/active_interaction/master.svg
289
289
  [6]: https://coveralls.io/r/orgsync/active_interaction?branch=master "Coverage Status"
290
- [7]: https://codeclimate.com/github/orgsync/active_interaction.png
290
+ [7]: https://codeclimate.com/github/orgsync/active_interaction/badges/gpa.svg
291
291
  [8]: https://codeclimate.com/github/orgsync/active_interaction "Code Climate"
292
292
  [9]: https://gemnasium.com/orgsync/active_interaction.svg
293
293
  [10]: https://gemnasium.com/orgsync/active_interaction "Dependency Status"
@@ -13,11 +13,16 @@ module ActiveInteraction
13
13
  send("#{name}=", value)
14
14
  end unless method_defined?(:[]=)
15
15
  end
16
+
17
+ class Errors
18
+ # Required for Rails < 3.2.13.
19
+ protected :initialize_dup
20
+ end
16
21
  end
17
22
 
18
23
  # @private
19
24
  class Hash
20
- # Required for Rails <= 4.0.2.
25
+ # Required for Rails < 4.0.0.
21
26
  def transform_keys
22
27
  result = {}
23
28
  each_key do |key|
@@ -31,7 +31,7 @@ module ActiveInteraction
31
31
  include ActiveModelable
32
32
  include Runnable
33
33
 
34
- validate :input_errors
34
+ define_callbacks :type_check
35
35
 
36
36
  class << self
37
37
  include Hashable
@@ -235,6 +235,14 @@ module ActiveInteraction
235
235
  end
236
236
  end
237
237
 
238
+ protected
239
+
240
+ def run_validations!
241
+ type_check
242
+
243
+ super if errors.empty?
244
+ end
245
+
238
246
  private
239
247
 
240
248
  # @param inputs [Hash{Symbol => Object}]
@@ -257,16 +265,16 @@ module ActiveInteraction
257
265
  begin
258
266
  public_send("#{name}=", filter.clean(inputs[name]))
259
267
  rescue InvalidValueError, MissingValueError, InvalidNestedValueError
260
- # Validators (#input_errors) will add errors if appropriate.
268
+ # #type_check will add errors if appropriate.
261
269
  end
262
270
  end
263
271
  end
264
272
 
265
- # @!group Validations
266
-
267
- def input_errors
268
- Validation.validate(self.class.filters, inputs).each do |error|
269
- errors.add_sym(*error)
273
+ def type_check
274
+ run_callbacks(:type_check) do
275
+ Validation.validate(self.class.filters, inputs).each do |error|
276
+ errors.add_sym(*error)
277
+ end
270
278
  end
271
279
  end
272
280
  end
@@ -39,6 +39,13 @@ module ActiveInteraction
39
39
  end
40
40
 
41
41
  module ClassMethods # rubocop:disable Documentation
42
+ # @param klass [Class]
43
+ def inherited(klass)
44
+ klass.transaction(transaction?, transaction_options.dup)
45
+
46
+ super
47
+ end
48
+
42
49
  # @param enable [Boolean]
43
50
  # @param options [Hash]
44
51
  #
@@ -171,9 +171,9 @@ module ActiveInteraction
171
171
  def merge_symbolic!(other)
172
172
  other.symbolic.each do |attribute, symbols|
173
173
  symbols.each do |symbol|
174
- unless symbolic[attribute].include?(symbol)
175
- symbolic[attribute] += [symbol]
176
- end
174
+ next if symbolic[attribute].include?(symbol)
175
+
176
+ symbolic[attribute] += [symbol]
177
177
  end
178
178
  end
179
179
  end
@@ -12,7 +12,7 @@ module ActiveInteraction
12
12
 
13
13
  # @return [Class]
14
14
  def klass
15
- @klass ||= self.class.slug.to_s.camelize.constantize
15
+ @klass ||= Object.const_get(self.class.slug.to_s.camelize, false)
16
16
  end
17
17
  end
18
18
  end
@@ -64,9 +64,11 @@ module ActiveInteraction
64
64
  fail InvalidFilterError, 'attribute names in array block'
65
65
  end
66
66
 
67
+ # rubocop:disable GuardClause
67
68
  if filter.default?
68
69
  fail InvalidDefaultError, 'default values in array block'
69
70
  end
71
+ # rubocop:enable GuardClause
70
72
  end
71
73
  end
72
74
  end
@@ -1,5 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'bigdecimal'
4
+
3
5
  module ActiveInteraction
4
6
  class Base
5
7
  # @!method self.decimal(*attributes, options = {})
@@ -46,7 +48,7 @@ module ActiveInteraction
46
48
  Float(value)
47
49
  BigDecimal.new(value, digits)
48
50
  rescue ArgumentError
49
- raise InvalidValueError, "Given value: #{value.inspect}"
51
+ raise InvalidValueError, "Given value: #{value.inspect}"
50
52
  end
51
53
 
52
54
  def klass