active_interaction 4.1.0 → 5.0.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +128 -1
  3. data/README.md +63 -28
  4. data/lib/active_interaction/array_input.rb +77 -0
  5. data/lib/active_interaction/base.rb +14 -98
  6. data/lib/active_interaction/concerns/active_recordable.rb +3 -3
  7. data/lib/active_interaction/concerns/missable.rb +2 -2
  8. data/lib/active_interaction/errors.rb +6 -88
  9. data/lib/active_interaction/exceptions.rb +47 -0
  10. data/lib/active_interaction/filter/column.rb +59 -0
  11. data/lib/active_interaction/filter/error.rb +40 -0
  12. data/lib/active_interaction/filter.rb +44 -53
  13. data/lib/active_interaction/filters/abstract_date_time_filter.rb +9 -6
  14. data/lib/active_interaction/filters/abstract_numeric_filter.rb +7 -3
  15. data/lib/active_interaction/filters/array_filter.rb +34 -6
  16. data/lib/active_interaction/filters/boolean_filter.rb +4 -3
  17. data/lib/active_interaction/filters/date_filter.rb +1 -1
  18. data/lib/active_interaction/filters/date_time_filter.rb +1 -1
  19. data/lib/active_interaction/filters/decimal_filter.rb +1 -1
  20. data/lib/active_interaction/filters/float_filter.rb +1 -1
  21. data/lib/active_interaction/filters/hash_filter.rb +23 -15
  22. data/lib/active_interaction/filters/integer_filter.rb +1 -1
  23. data/lib/active_interaction/filters/interface_filter.rb +12 -12
  24. data/lib/active_interaction/filters/object_filter.rb +9 -3
  25. data/lib/active_interaction/filters/record_filter.rb +21 -11
  26. data/lib/active_interaction/filters/string_filter.rb +1 -1
  27. data/lib/active_interaction/filters/symbol_filter.rb +1 -1
  28. data/lib/active_interaction/filters/time_filter.rb +4 -4
  29. data/lib/active_interaction/hash_input.rb +43 -0
  30. data/lib/active_interaction/input.rb +23 -0
  31. data/lib/active_interaction/inputs.rb +157 -46
  32. data/lib/active_interaction/locale/en.yml +0 -1
  33. data/lib/active_interaction/locale/fr.yml +0 -1
  34. data/lib/active_interaction/locale/it.yml +0 -1
  35. data/lib/active_interaction/locale/ja.yml +0 -1
  36. data/lib/active_interaction/locale/pt-BR.yml +0 -1
  37. data/lib/active_interaction/modules/validation.rb +6 -17
  38. data/lib/active_interaction/version.rb +1 -1
  39. data/lib/active_interaction.rb +43 -36
  40. data/spec/active_interaction/array_input_spec.rb +166 -0
  41. data/spec/active_interaction/base_spec.rb +15 -240
  42. data/spec/active_interaction/concerns/active_modelable_spec.rb +3 -3
  43. data/spec/active_interaction/concerns/active_recordable_spec.rb +7 -7
  44. data/spec/active_interaction/concerns/hashable_spec.rb +8 -8
  45. data/spec/active_interaction/concerns/missable_spec.rb +9 -9
  46. data/spec/active_interaction/concerns/runnable_spec.rb +34 -32
  47. data/spec/active_interaction/errors_spec.rb +60 -43
  48. data/spec/active_interaction/{filter_column_spec.rb → filter/column_spec.rb} +3 -10
  49. data/spec/active_interaction/filter_spec.rb +6 -6
  50. data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +2 -2
  51. data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +2 -2
  52. data/spec/active_interaction/filters/array_filter_spec.rb +99 -16
  53. data/spec/active_interaction/filters/boolean_filter_spec.rb +12 -11
  54. data/spec/active_interaction/filters/date_filter_spec.rb +32 -27
  55. data/spec/active_interaction/filters/date_time_filter_spec.rb +34 -29
  56. data/spec/active_interaction/filters/decimal_filter_spec.rb +20 -18
  57. data/spec/active_interaction/filters/file_filter_spec.rb +7 -7
  58. data/spec/active_interaction/filters/float_filter_spec.rb +19 -17
  59. data/spec/active_interaction/filters/hash_filter_spec.rb +16 -18
  60. data/spec/active_interaction/filters/integer_filter_spec.rb +24 -22
  61. data/spec/active_interaction/filters/interface_filter_spec.rb +105 -82
  62. data/spec/active_interaction/filters/object_filter_spec.rb +52 -36
  63. data/spec/active_interaction/filters/record_filter_spec.rb +61 -39
  64. data/spec/active_interaction/filters/string_filter_spec.rb +7 -7
  65. data/spec/active_interaction/filters/symbol_filter_spec.rb +6 -6
  66. data/spec/active_interaction/filters/time_filter_spec.rb +57 -34
  67. data/spec/active_interaction/hash_input_spec.rb +58 -0
  68. data/spec/active_interaction/i18n_spec.rb +22 -17
  69. data/spec/active_interaction/inputs_spec.rb +167 -23
  70. data/spec/active_interaction/integration/array_interaction_spec.rb +3 -7
  71. data/spec/active_interaction/modules/validation_spec.rb +8 -31
  72. data/spec/spec_helper.rb +8 -0
  73. data/spec/support/concerns.rb +2 -2
  74. data/spec/support/filters.rb +27 -51
  75. data/spec/support/interactions.rb +4 -4
  76. metadata +40 -91
  77. data/lib/active_interaction/filter_column.rb +0 -57
@@ -1,10 +1,10 @@
1
1
  shared_context 'filters' do
2
+ subject(:filter) { described_class.new(name, options, &block) }
3
+
2
4
  let(:block) { nil }
3
5
  let(:name) { SecureRandom.hex.to_sym }
4
6
  let(:options) { {} }
5
7
 
6
- subject(:filter) { described_class.new(name, options, &block) }
7
-
8
8
  shared_context 'optional' do
9
9
  before do
10
10
  options[:default] = nil
@@ -45,71 +45,35 @@ shared_examples_for 'a filter' do
45
45
  end
46
46
  end
47
47
 
48
- describe '#cast' do
49
- let(:value) { nil }
50
- let(:result) { filter.send(:cast, value, nil) }
51
-
52
- context 'optional' do
53
- include_context 'optional'
54
-
55
- it 'returns nil' do
56
- expect(result).to be_nil
57
- end
58
- end
59
-
60
- context 'required' do
61
- include_context 'required'
62
-
63
- it 'raises an error' do
64
- expect { result }.to raise_error ActiveInteraction::MissingValueError
65
- end
66
-
67
- context 'with an invalid default' do
68
- let(:value) { Object.new }
69
-
70
- it 'raises an error' do
71
- expect { result }.to raise_error ActiveInteraction::InvalidValueError
72
- end
73
- end
74
- end
75
-
76
- # BasicObject is missing a lot of methods
77
- context 'with a BasicObject' do
78
- let(:value) { BasicObject.new }
79
-
80
- it 'raises an error' do
81
- expect { result }.to raise_error ActiveInteraction::InvalidValueError
82
- end
83
- end
84
- end
85
-
86
- describe '#clean' do
48
+ describe '#process' do
87
49
  let(:value) { nil }
88
50
 
89
51
  context 'optional' do
90
52
  include_context 'optional'
91
53
 
92
54
  it 'returns the default' do
93
- expect(filter.clean(value, nil)).to eql options[:default]
55
+ expect(filter.process(value, nil).value).to eql options[:default]
94
56
  end
95
57
  end
96
58
 
97
59
  context 'required' do
98
60
  include_context 'required'
99
61
 
100
- it 'raises an error' do
101
- expect do
102
- filter.clean(value, nil)
103
- end.to raise_error ActiveInteraction::MissingValueError
62
+ it 'indicates an error' do
63
+ error = filter.process(value, nil).errors.first
64
+
65
+ expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
66
+ expect(error.type).to be :missing
104
67
  end
105
68
 
106
69
  context 'with an invalid value' do
107
70
  let(:value) { Object.new }
108
71
 
109
- it 'raises an error' do
110
- expect do
111
- filter.clean(value, nil)
112
- end.to raise_error ActiveInteraction::InvalidValueError
72
+ it 'indicates an error' do
73
+ error = filter.process(value, nil).errors.first
74
+
75
+ expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
76
+ expect(error.type).to be :invalid_type
113
77
  end
114
78
  end
115
79
  end
@@ -121,10 +85,22 @@ shared_examples_for 'a filter' do
121
85
 
122
86
  it 'raises an error' do
123
87
  expect do
124
- filter.clean(value, nil)
88
+ filter.process(value, nil)
125
89
  end.to raise_error ActiveInteraction::InvalidDefaultError
126
90
  end
127
91
  end
92
+
93
+ # BasicObject is missing a lot of methods
94
+ context 'with a BasicObject' do
95
+ let(:value) { BasicObject.new }
96
+
97
+ it 'indicates an error' do
98
+ error = filter.process(value, nil).errors.first
99
+
100
+ expect(error).to be_an_instance_of ActiveInteraction::Filter::Error
101
+ expect(error.type).to be :invalid_type
102
+ end
103
+ end
128
104
  end
129
105
 
130
106
  describe '#default' do
@@ -14,7 +14,7 @@ shared_context 'interactions' do
14
14
  let(:result) { outcome.result }
15
15
  end
16
16
 
17
- shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
17
+ shared_examples_for 'an interaction' do |type, generator, adjust_output = nil, **filter_options|
18
18
  include_context 'interactions'
19
19
 
20
20
  let(:described_class) do
@@ -73,7 +73,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
73
73
  end
74
74
 
75
75
  it 'returns the correct value for :required' do
76
- expect(result[:required]).to eql required
76
+ expect(result[:required]).to eql(adjust_output ? adjust_output.call(required) : required)
77
77
  end
78
78
 
79
79
  it 'returns nil for :optional' do
@@ -107,7 +107,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
107
107
  before { inputs[:optional] = optional }
108
108
 
109
109
  it 'returns the correct value for :optional' do
110
- expect(result[:optional]).to eql optional
110
+ expect(result[:optional]).to eql(adjust_output ? adjust_output.call(optional) : optional)
111
111
  end
112
112
  end
113
113
 
@@ -117,7 +117,7 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
117
117
  before { inputs[:default] = default }
118
118
 
119
119
  it 'returns the correct value for :default' do
120
- expect(result[:default]).to eql default
120
+ expect(result[:default]).to eql(adjust_output ? adjust_output.call(default) : default)
121
121
  end
122
122
  end
123
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
@@ -9,15 +9,15 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-12-30 00:00:00.000000000 Z
12
+ date: 2022-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activemodel
15
+ name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '5'
20
+ version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '8'
@@ -27,72 +27,10 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '5'
30
+ version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '8'
34
- - !ruby/object:Gem::Dependency
35
- name: activesupport
36
- requirement: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '5'
41
- - - "<"
42
- - !ruby/object:Gem::Version
43
- version: '8'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: '5'
51
- - - "<"
52
- - !ruby/object:Gem::Version
53
- version: '8'
54
- - !ruby/object:Gem::Dependency
55
- name: actionpack
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- - !ruby/object:Gem::Dependency
69
- name: activerecord
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- type: :development
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- - !ruby/object:Gem::Dependency
83
- name: benchmark-ips
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '2.7'
89
- type: :development
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '2.7'
96
34
  - !ruby/object:Gem::Dependency
97
35
  name: kramdown
98
36
  requirement: !ruby/object:Gem::Requirement
@@ -141,14 +79,14 @@ dependencies:
141
79
  requirements:
142
80
  - - "~>"
143
81
  - !ruby/object:Gem::Version
144
- version: 1.24.0
82
+ version: 1.26.1
145
83
  type: :development
146
84
  prerelease: false
147
85
  version_requirements: !ruby/object:Gem::Requirement
148
86
  requirements:
149
87
  - - "~>"
150
88
  - !ruby/object:Gem::Version
151
- version: 1.24.0
89
+ version: 1.26.1
152
90
  - !ruby/object:Gem::Dependency
153
91
  name: rubocop-rake
154
92
  requirement: !ruby/object:Gem::Requirement
@@ -169,45 +107,47 @@ dependencies:
169
107
  requirements:
170
108
  - - "~>"
171
109
  - !ruby/object:Gem::Version
172
- version: 2.7.0
110
+ version: 2.9.0
173
111
  type: :development
174
112
  prerelease: false
175
113
  version_requirements: !ruby/object:Gem::Requirement
176
114
  requirements:
177
115
  - - "~>"
178
116
  - !ruby/object:Gem::Version
179
- version: 2.7.0
117
+ version: 2.9.0
180
118
  - !ruby/object:Gem::Dependency
181
- name: yard
119
+ name: sqlite3
182
120
  requirement: !ruby/object:Gem::Requirement
183
121
  requirements:
184
- - - "~>"
122
+ - - ">="
185
123
  - !ruby/object:Gem::Version
186
- version: '0.9'
124
+ version: '0'
187
125
  type: :development
188
126
  prerelease: false
189
127
  version_requirements: !ruby/object:Gem::Requirement
190
128
  requirements:
191
- - - "~>"
129
+ - - ">="
192
130
  - !ruby/object:Gem::Version
193
- version: '0.9'
131
+ version: '0'
194
132
  - !ruby/object:Gem::Dependency
195
- name: sqlite3
133
+ name: yard
196
134
  requirement: !ruby/object:Gem::Requirement
197
135
  requirements:
198
- - - ">="
136
+ - - "~>"
199
137
  - !ruby/object:Gem::Version
200
- version: '0'
138
+ version: '0.9'
201
139
  type: :development
202
140
  prerelease: false
203
141
  version_requirements: !ruby/object:Gem::Requirement
204
142
  requirements:
205
- - - ">="
143
+ - - "~>"
206
144
  - !ruby/object:Gem::Version
207
- version: '0'
208
- description: |2
209
- ActiveInteraction manages application-specific business logic. It is an
210
- implementation of the command pattern in Ruby.
145
+ version: '0.9'
146
+ description: |
147
+ ActiveInteraction manages application-specific business logic. It is an
148
+ implementation of what are called service objects, interactors, or the
149
+ command pattern. No matter what you call it, its built to work seamlessly
150
+ with Rails.
211
151
  email:
212
152
  - aaron.lasseigne@gmail.com
213
153
  - taylor@fausak.me
@@ -220,6 +160,7 @@ files:
220
160
  - LICENSE.md
221
161
  - README.md
222
162
  - lib/active_interaction.rb
163
+ - lib/active_interaction/array_input.rb
223
164
  - lib/active_interaction/base.rb
224
165
  - lib/active_interaction/concerns/active_modelable.rb
225
166
  - lib/active_interaction/concerns/active_recordable.rb
@@ -227,8 +168,10 @@ files:
227
168
  - lib/active_interaction/concerns/missable.rb
228
169
  - lib/active_interaction/concerns/runnable.rb
229
170
  - lib/active_interaction/errors.rb
171
+ - lib/active_interaction/exceptions.rb
230
172
  - lib/active_interaction/filter.rb
231
- - lib/active_interaction/filter_column.rb
173
+ - lib/active_interaction/filter/column.rb
174
+ - lib/active_interaction/filter/error.rb
232
175
  - lib/active_interaction/filters/abstract_date_time_filter.rb
233
176
  - lib/active_interaction/filters/abstract_numeric_filter.rb
234
177
  - lib/active_interaction/filters/array_filter.rb
@@ -247,6 +190,8 @@ files:
247
190
  - lib/active_interaction/filters/symbol_filter.rb
248
191
  - lib/active_interaction/filters/time_filter.rb
249
192
  - lib/active_interaction/grouped_input.rb
193
+ - lib/active_interaction/hash_input.rb
194
+ - lib/active_interaction/input.rb
250
195
  - lib/active_interaction/inputs.rb
251
196
  - lib/active_interaction/locale/en.yml
252
197
  - lib/active_interaction/locale/fr.yml
@@ -255,6 +200,7 @@ files:
255
200
  - lib/active_interaction/locale/pt-BR.yml
256
201
  - lib/active_interaction/modules/validation.rb
257
202
  - lib/active_interaction/version.rb
203
+ - spec/active_interaction/array_input_spec.rb
258
204
  - spec/active_interaction/base_spec.rb
259
205
  - spec/active_interaction/concerns/active_modelable_spec.rb
260
206
  - spec/active_interaction/concerns/active_recordable_spec.rb
@@ -262,7 +208,7 @@ files:
262
208
  - spec/active_interaction/concerns/missable_spec.rb
263
209
  - spec/active_interaction/concerns/runnable_spec.rb
264
210
  - spec/active_interaction/errors_spec.rb
265
- - spec/active_interaction/filter_column_spec.rb
211
+ - spec/active_interaction/filter/column_spec.rb
266
212
  - spec/active_interaction/filter_spec.rb
267
213
  - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
268
214
  - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
@@ -282,6 +228,7 @@ files:
282
228
  - spec/active_interaction/filters/symbol_filter_spec.rb
283
229
  - spec/active_interaction/filters/time_filter_spec.rb
284
230
  - spec/active_interaction/grouped_input_spec.rb
231
+ - spec/active_interaction/hash_input_spec.rb
285
232
  - spec/active_interaction/i18n_spec.rb
286
233
  - spec/active_interaction/inputs_spec.rb
287
234
  - spec/active_interaction/integration/array_interaction_spec.rb
@@ -302,13 +249,13 @@ files:
302
249
  - spec/support/concerns.rb
303
250
  - spec/support/filters.rb
304
251
  - spec/support/interactions.rb
305
- homepage:
252
+ homepage: https://github.com/AaronLasseigne/active_interaction
306
253
  licenses:
307
254
  - MIT
308
255
  metadata:
309
256
  homepage_uri: https://github.com/AaronLasseigne/active_interaction
310
257
  source_code_uri: https://github.com/AaronLasseigne/active_interaction
311
- changelog_uri: https://github.com/AaronLasseigne/active_interaction/blob/master/CHANGELOG.md
258
+ changelog_uri: https://github.com/AaronLasseigne/active_interaction/blob/main/CHANGELOG.md
312
259
  rubygems_mfa_required: 'true'
313
260
  post_install_message:
314
261
  rdoc_options: []
@@ -318,18 +265,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
265
  requirements:
319
266
  - - ">="
320
267
  - !ruby/object:Gem::Version
321
- version: '2.5'
268
+ version: '2.7'
322
269
  required_rubygems_version: !ruby/object:Gem::Requirement
323
270
  requirements:
324
271
  - - ">="
325
272
  - !ruby/object:Gem::Version
326
273
  version: '0'
327
274
  requirements: []
328
- rubygems_version: 3.2.15
275
+ rubygems_version: 3.3.7
329
276
  signing_key:
330
277
  specification_version: 4
331
278
  summary: Manage application specific business logic.
332
279
  test_files:
280
+ - spec/active_interaction/array_input_spec.rb
333
281
  - spec/active_interaction/base_spec.rb
334
282
  - spec/active_interaction/concerns/active_modelable_spec.rb
335
283
  - spec/active_interaction/concerns/active_recordable_spec.rb
@@ -337,7 +285,7 @@ test_files:
337
285
  - spec/active_interaction/concerns/missable_spec.rb
338
286
  - spec/active_interaction/concerns/runnable_spec.rb
339
287
  - spec/active_interaction/errors_spec.rb
340
- - spec/active_interaction/filter_column_spec.rb
288
+ - spec/active_interaction/filter/column_spec.rb
341
289
  - spec/active_interaction/filter_spec.rb
342
290
  - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
343
291
  - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
@@ -357,6 +305,7 @@ test_files:
357
305
  - spec/active_interaction/filters/symbol_filter_spec.rb
358
306
  - spec/active_interaction/filters/time_filter_spec.rb
359
307
  - spec/active_interaction/grouped_input_spec.rb
308
+ - spec/active_interaction/hash_input_spec.rb
360
309
  - spec/active_interaction/i18n_spec.rb
361
310
  - spec/active_interaction/inputs_spec.rb
362
311
  - spec/active_interaction/integration/array_interaction_spec.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveInteraction
4
- # A minimal implementation of an `ActiveRecord::ConnectionAdapters::Column`.
5
- class FilterColumn
6
- # @return [nil]
7
- attr_reader :limit
8
-
9
- # @return [Symbol]
10
- attr_reader :type
11
-
12
- class << self
13
- # Find or create the `FilterColumn` for a specific type.
14
- #
15
- # @param type [Symbol] A database column type.
16
- #
17
- # @example
18
- # FilterColumn.intern(:string)
19
- # # => #<ActiveInteraction::FilterColumn:0x007feeaa649c @type=:string>
20
- #
21
- # FilterColumn.intern(:string)
22
- # # => #<ActiveInteraction::FilterColumn:0x007feeaa649c @type=:string>
23
- #
24
- # FilterColumn.intern(:boolean)
25
- # # => #<ActiveInteraction::FilterColumn:0x007feeab8a08 @type=:boolean>
26
- #
27
- # @return [FilterColumn]
28
- def intern(type)
29
- @columns ||= {}
30
- @columns[type] ||= new(type)
31
- end
32
-
33
- private :new
34
- end
35
-
36
- # @param type [type] The database column type.
37
- #
38
- # @private
39
- def initialize(type)
40
- @type = type
41
- end
42
-
43
- # Returns `true` if the column is either of type :integer or :float.
44
- #
45
- # @return [Boolean]
46
- def number?
47
- %i[integer float].include?(type)
48
- end
49
-
50
- # Returns `true` if the column is of type :string.
51
- #
52
- # @return [Boolean]
53
- def text?
54
- type == :string
55
- end
56
- end
57
- end