convenient_service 0.22.0 → 0.24.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 +4 -4
- data/lib/convenient_service/dependencies/queries/version.rb +18 -0
- data/lib/convenient_service/service/configs/standard.rb +7 -3
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_backtrace.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_cause.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_class.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_exception.rb +2 -2
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_line.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_message.rb +1 -1
- data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/constants.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_formatted_exceptions.rb +35 -0
- data/lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb +34 -0
- data/lib/convenient_service/service/plugins/{has_j_send_result/entities/result/plugins/can_have_modified_data.rb → can_have_handled_exceptions.rb} +1 -2
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands/cast_step_aware_enumerable.rb → can_have_service_aware_enumerables/commands/cast_service_aware_enumerable.rb} +19 -19
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb → can_have_service_aware_enumerables/commands/cast_service_aware_enumerator.rb} +15 -15
- data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/commands.rb +9 -0
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → can_have_service_aware_enumerables}/concern.rb +18 -9
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/arithmetic_sequence_enumerator.rb +6 -6
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/array.rb +3 -3
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/base.rb +100 -112
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/boolean.rb +3 -3
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/chain_enumerator.rb +21 -21
- data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/entities/service_aware_enumerables/enumerable.rb +1761 -0
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/enumerator.rb +49 -27
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/hash.rb +3 -3
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/lazy_enumerator/jruby.rb +40 -40
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/lazy_enumerator.rb +133 -133
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/object.rb +4 -4
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/object_or_nil.rb +3 -3
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/set.rb +3 -3
- data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/entities/service_aware_enumerables.rb +21 -0
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands.rb → can_have_service_aware_enumerables/entities.rb} +1 -2
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → can_have_service_aware_enumerables}/exceptions.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables.rb +12 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_used_in_service_aware_enumerables/concern.rb +52 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_used_in_service_aware_enumerables.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +2 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +4 -4
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb +61 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception.rb +8 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception.rb +8 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/concern.rb +97 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/base.rb +153 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/many.rb +141 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/none.rb +106 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/one.rb +146 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes.rb +54 -0
- data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables}/entities.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/{can_have_modified_data → can_be_used_in_service_aware_enumerables}/exceptions.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables.rb +10 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb +28 -10
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/exceptions.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +3 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +3 -3
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb +0 -2
- data/lib/convenient_service/service/plugins.rb +3 -1
- data/lib/convenient_service/version.rb +1 -1
- metadata +48 -34
- data/lib/convenient_service/service/plugins/can_have_step_aware_collections.rb +0 -12
- data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables/entities/step_aware_enumerables/enumerable.rb +0 -1113
- data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables/entities/step_aware_enumerables.rb +0 -21
- data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables.rb +0 -12
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_modified_data/concern.rb +0 -109
- /data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands.rb +0 -0
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
module ConvenientService
|
|
9
9
|
module Service
|
|
10
10
|
module Plugins
|
|
11
|
-
module
|
|
11
|
+
module CanHaveServiceAwareEnumerables
|
|
12
12
|
module Entities
|
|
13
|
-
module
|
|
13
|
+
module ServiceAwareEnumerables
|
|
14
14
|
class Base
|
|
15
15
|
include Support::AbstractMethod
|
|
16
16
|
|
|
@@ -67,10 +67,10 @@ module ConvenientService
|
|
|
67
67
|
# def initialize(object:, organizer:, propagated_result:)
|
|
68
68
|
# if object.is_a?(::Enumerator)
|
|
69
69
|
# mapping = {
|
|
70
|
-
# ::Enumerator => Entities::
|
|
71
|
-
# ::Enumerator::Lazy => Entities::
|
|
72
|
-
# ::Enumerator::Chain => Entities::
|
|
73
|
-
# ::Enumerator::ArithmeticSequence => Entities::
|
|
70
|
+
# ::Enumerator => Entities::ServiceAwareEnumerables::Enumerator,
|
|
71
|
+
# ::Enumerator::Lazy => Entities::ServiceAwareEnumerables::LazyEnumerator,
|
|
72
|
+
# ::Enumerator::Chain => Entities::ServiceAwareEnumerables::ChainEnumerator,
|
|
73
|
+
# ::Enumerator::ArithmeticSequence => Entities::ServiceAwareEnumerables::ArithmeticSequenceEnumerator
|
|
74
74
|
# }
|
|
75
75
|
#
|
|
76
76
|
# raise "No mapping for class `#{object.class}`." unless mapping[object.class]
|
|
@@ -123,259 +123,247 @@ module ConvenientService
|
|
|
123
123
|
##
|
|
124
124
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
125
125
|
# @param iterator_block [Proc]
|
|
126
|
-
# @return [ConvenientService::Service::Plugins::
|
|
126
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
127
127
|
#
|
|
128
128
|
def with_processing_return_value_as_object(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
129
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
129
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_object_from(value, propagated_result) }
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
##
|
|
133
133
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
134
134
|
# @param iterator_block [Proc]
|
|
135
|
-
# @return [ConvenientService::Service::Plugins::
|
|
135
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
136
136
|
#
|
|
137
137
|
def with_processing_return_value_as_object_or_nil(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
138
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
138
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_object_or_nil_from(value, propagated_result) }
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
##
|
|
142
142
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
143
143
|
# @param iterator_block [Proc]
|
|
144
|
-
# @return [ConvenientService::Service::Plugins::
|
|
144
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
145
145
|
#
|
|
146
146
|
def with_processing_return_value_as_boolean(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
147
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
147
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_boolean_from(value, propagated_result) }
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
##
|
|
151
151
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
152
152
|
# @param iterator_block [Proc]
|
|
153
|
-
# @return [ConvenientService::Service::Plugins::
|
|
153
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
154
154
|
#
|
|
155
155
|
def with_processing_return_value_as_enumerable(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
156
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
156
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_enumerable_from(value, propagated_result) }
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
##
|
|
160
160
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
161
161
|
# @param iterator_block [Proc]
|
|
162
|
-
# @return [ConvenientService::Service::Plugins::
|
|
162
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
163
163
|
#
|
|
164
164
|
def with_processing_return_value_as_array(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
165
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
165
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_array_from(value, propagated_result) }
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
##
|
|
169
169
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
170
170
|
# @param iterator_block [Proc]
|
|
171
|
-
# @return [ConvenientService::Service::Plugins::
|
|
171
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
172
172
|
#
|
|
173
173
|
def with_processing_return_value_as_hash(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
174
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
174
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_hash_from(value, propagated_result) }
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
##
|
|
178
178
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
179
179
|
# @param iterator_block [Proc]
|
|
180
|
-
# @return [ConvenientService::Service::Plugins::
|
|
180
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
181
181
|
#
|
|
182
182
|
def with_processing_return_value_as_set(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
183
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
183
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_set_from(value, propagated_result) }
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
##
|
|
187
187
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
188
188
|
# @param iterator_block [Proc]
|
|
189
|
-
# @return [ConvenientService::Service::Plugins::
|
|
189
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator]
|
|
190
190
|
#
|
|
191
191
|
def with_processing_return_value_as_enumerator(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
192
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
192
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_enumerator_from(value, propagated_result) }
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
##
|
|
196
|
-
# @return [ConvenientService::Service::Plugins::
|
|
196
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator]
|
|
197
197
|
#
|
|
198
198
|
alias_method :with_processing_return_value_as_enumerator_generator, :with_processing_return_value_as_enumerator
|
|
199
199
|
|
|
200
200
|
##
|
|
201
201
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
202
202
|
# @param iterator_block [Proc]
|
|
203
|
-
# @return [ConvenientService::Service::Plugins::
|
|
203
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::LazyEnumerator]
|
|
204
204
|
#
|
|
205
205
|
def with_processing_return_value_as_lazy_enumerator(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
206
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
206
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_lazy_enumerator_from(value, propagated_result) }
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
##
|
|
210
210
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
211
211
|
# @param iterator_block [Proc]
|
|
212
|
-
# @return [ConvenientService::Service::Plugins::
|
|
212
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
213
213
|
#
|
|
214
214
|
def with_processing_return_value_as_chain_enumerator(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
215
|
-
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result|
|
|
215
|
+
with_processing_return_value(iterator_arguments, iterator_block) { |value, propagated_result| service_aware_chain_enumerator_from(value, propagated_result) }
|
|
216
216
|
end
|
|
217
217
|
|
|
218
218
|
##
|
|
219
219
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
220
220
|
# @param iterator_block [Proc]
|
|
221
|
-
# @return [ConvenientService::Service::Plugins::
|
|
221
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ArithmeticSequenceEnumerator]
|
|
222
222
|
#
|
|
223
223
|
def with_processing_return_value_as_arithmetic_sequence_enumerator(iterator_arguments = Support::Arguments.null_arguments, &iterator_block)
|
|
224
|
-
with_processing_return_value(arguments, iterator_block) { |value, propagated_result|
|
|
224
|
+
with_processing_return_value(arguments, iterator_block) { |value, propagated_result| service_aware_arithmetic_sequence_enumerator_from(value, propagated_result) }
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
##
|
|
228
228
|
# @param iteration_block [Proc, nil]
|
|
229
229
|
# @return [Proc]
|
|
230
230
|
#
|
|
231
|
-
|
|
231
|
+
# @internal
|
|
232
|
+
# NOTE: It may look very appealing to return data objects instead of hashes. For example:
|
|
233
|
+
# # With hashes.
|
|
234
|
+
# result =
|
|
235
|
+
# service_aware_enumerable(users)
|
|
236
|
+
# .map { |user| step ProcessUser, in: :user, out: [:attributes, :associations] }
|
|
237
|
+
# .each { |values| p [values[:attributes], values[:associations]] }
|
|
238
|
+
# .result(data_key: :items)
|
|
239
|
+
#
|
|
240
|
+
# result.data[:items]
|
|
241
|
+
# # => [{attributes: {}, associations: []}, {attributes: {}, associations: []}]
|
|
242
|
+
#
|
|
243
|
+
# # With data objects.
|
|
244
|
+
# result =
|
|
245
|
+
# service_aware_enumerable(users)
|
|
246
|
+
# .map { |user| step ProcessUser, in: :user, out: [:attributes, :associations] }
|
|
247
|
+
# .each { |data| p [data.attributes, data.associations] }
|
|
248
|
+
# .result(data_key: :items)
|
|
249
|
+
#
|
|
250
|
+
# result.data[:items]
|
|
251
|
+
# # => [<...Data attributes: {}, associations: []>, <...Data attributes: {}, associations: []>]
|
|
252
|
+
#
|
|
253
|
+
# But:
|
|
254
|
+
# - Is it OK to return nested data objects from results?
|
|
255
|
+
# - If not, how can those nested data objects be efficiently converted into hashes only for the results (data may return arrays, hashes, sets, enumerators, arithmetic sequences, etc.)?
|
|
256
|
+
#
|
|
257
|
+
# next data.one? ? data.values.first : result.create_data(data)
|
|
258
|
+
#
|
|
259
|
+
def service_aware_iteration_block_from(iteration_block)
|
|
232
260
|
return unless iteration_block
|
|
233
261
|
|
|
234
262
|
proc do |*args|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if value.success?
|
|
240
|
-
next true if value.outputs.none?
|
|
241
|
-
|
|
242
|
-
##
|
|
243
|
-
# NOTE: It may look very appealing to return data objects instead of hashes. For example:
|
|
244
|
-
# # With hashes.
|
|
245
|
-
# result =
|
|
246
|
-
# step_aware_enumerable(users)
|
|
247
|
-
# .map { |user| step ProcessUser, in: :user, out: [:attributes, :associations] }
|
|
248
|
-
# .each { |values| p [values[:attributes], values[:associations]] }
|
|
249
|
-
# .result(data_key: :items)
|
|
250
|
-
#
|
|
251
|
-
# result.data[:items]
|
|
252
|
-
# # => [{attributes: {}, associations: []}, {attributes: {}, associations: []}]
|
|
253
|
-
#
|
|
254
|
-
# # With data objects.
|
|
255
|
-
# result =
|
|
256
|
-
# step_aware_enumerable(users)
|
|
257
|
-
# .map { |user| step ProcessUser, in: :user, out: [:attributes, :associations] }
|
|
258
|
-
# .each { |data| p [data.attributes, data.associations] }
|
|
259
|
-
# .result(data_key: :items)
|
|
260
|
-
#
|
|
261
|
-
# result.data[:items]
|
|
262
|
-
# # => [<...Data attributes: {}, associations: []>, <...Data attributes: {}, associations: []>]
|
|
263
|
-
#
|
|
264
|
-
# But:
|
|
265
|
-
# - Is it OK to return nested data objects from results?
|
|
266
|
-
# - If not, how can those nested data objects be efficiently converted into hashes only for the results (data may return arrays, hashes, sets, enumerators, arithmetic sequences, etc.)?
|
|
267
|
-
#
|
|
268
|
-
# next value.outputs.one? ? value.output_values.values.first : value.result.create_data(value.output_values)
|
|
269
|
-
|
|
270
|
-
next value.outputs.one? ? value.output_values.values.first : value.output_values
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
if value.failure?
|
|
274
|
-
next value.outputs.none? ? false : nil
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
throw :propagated_result, {propagated_result: value.result}
|
|
263
|
+
service = iteration_block.call(*args)
|
|
264
|
+
|
|
265
|
+
service.to_service_aware_iteration_block_value
|
|
278
266
|
end
|
|
279
267
|
end
|
|
280
268
|
|
|
281
269
|
##
|
|
282
270
|
# @param object [Object] Can be any type.
|
|
283
271
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
284
|
-
# @return [ConvenientService::Service::Plugins::
|
|
272
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
285
273
|
#
|
|
286
|
-
def
|
|
274
|
+
def service_aware_object_from(object, propagated_result)
|
|
287
275
|
# TODO: Cast.
|
|
288
|
-
Entities::
|
|
276
|
+
Entities::ServiceAwareEnumerables::Object.new(object: object, organizer: organizer, propagated_result: propagated_result)
|
|
289
277
|
end
|
|
290
278
|
|
|
291
279
|
##
|
|
292
280
|
# @param object [Object] Can be any type.
|
|
293
281
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
294
|
-
# @return [ConvenientService::Service::Plugins::
|
|
282
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
295
283
|
#
|
|
296
|
-
def
|
|
297
|
-
Entities::
|
|
284
|
+
def service_aware_object_or_nil_from(object, propagated_result)
|
|
285
|
+
Entities::ServiceAwareEnumerables::ObjectOrNil.new(object: object, organizer: organizer, propagated_result: propagated_result)
|
|
298
286
|
end
|
|
299
287
|
|
|
300
288
|
##
|
|
301
289
|
# @param boolean [Boolean].
|
|
302
290
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
303
|
-
# @return [ConvenientService::Service::Plugins::
|
|
291
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
304
292
|
#
|
|
305
|
-
def
|
|
306
|
-
Entities::
|
|
293
|
+
def service_aware_boolean_from(boolean, propagated_result)
|
|
294
|
+
Entities::ServiceAwareEnumerables::Boolean.new(object: boolean, organizer: organizer, propagated_result: propagated_result)
|
|
307
295
|
end
|
|
308
296
|
|
|
309
297
|
##
|
|
310
298
|
# @param enumerable [Enumerable]
|
|
311
299
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
312
|
-
# @return [ConvenientService::Service::Plugins::
|
|
300
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
|
|
313
301
|
#
|
|
314
|
-
def
|
|
315
|
-
Entities::
|
|
302
|
+
def service_aware_enumerable_from(enumerable, propagated_result)
|
|
303
|
+
Entities::ServiceAwareEnumerables::Enumerable.new(object: enumerable, organizer: organizer, propagated_result: propagated_result)
|
|
316
304
|
end
|
|
317
305
|
|
|
318
306
|
##
|
|
319
307
|
# @param array [Array]
|
|
320
308
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
321
|
-
# @return [ConvenientService::Service::Plugins::
|
|
309
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
|
|
322
310
|
#
|
|
323
|
-
def
|
|
324
|
-
Entities::
|
|
311
|
+
def service_aware_array_from(array, propagated_result)
|
|
312
|
+
Entities::ServiceAwareEnumerables::Array.new(object: array, organizer: organizer, propagated_result: propagated_result)
|
|
325
313
|
end
|
|
326
314
|
|
|
327
315
|
##
|
|
328
316
|
# @param hash [Hash]
|
|
329
317
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
330
|
-
# @return [ConvenientService::Service::Plugins::
|
|
318
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
|
|
331
319
|
#
|
|
332
|
-
def
|
|
333
|
-
Entities::
|
|
320
|
+
def service_aware_hash_from(hash, propagated_result)
|
|
321
|
+
Entities::ServiceAwareEnumerables::Hash.new(object: hash, organizer: organizer, propagated_result: propagated_result)
|
|
334
322
|
end
|
|
335
323
|
|
|
336
324
|
##
|
|
337
325
|
# @param set [Set]
|
|
338
326
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
339
|
-
# @return [ConvenientService::Service::Plugins::
|
|
327
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
|
|
340
328
|
#
|
|
341
|
-
def
|
|
342
|
-
Entities::
|
|
329
|
+
def service_aware_set_from(set, propagated_result)
|
|
330
|
+
Entities::ServiceAwareEnumerables::Set.new(object: set, organizer: organizer, propagated_result: propagated_result)
|
|
343
331
|
end
|
|
344
332
|
|
|
345
333
|
##
|
|
346
334
|
# @param enumerator [Enumerator]
|
|
347
335
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
348
|
-
# @return [ConvenientService::Service::Plugins::
|
|
336
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator]
|
|
349
337
|
#
|
|
350
|
-
def
|
|
351
|
-
Entities::
|
|
338
|
+
def service_aware_enumerator_from(enumerator, propagated_result)
|
|
339
|
+
Entities::ServiceAwareEnumerables::Enumerator.new(object: enumerator, organizer: organizer, propagated_result: propagated_result)
|
|
352
340
|
end
|
|
353
341
|
|
|
354
342
|
##
|
|
355
343
|
# @param lazy_enumerator [Enumerator]
|
|
356
344
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
357
|
-
# @return [ConvenientService::Service::Plugins::
|
|
345
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator]
|
|
358
346
|
#
|
|
359
|
-
def
|
|
360
|
-
Entities::
|
|
347
|
+
def service_aware_lazy_enumerator_from(lazy_enumerator, propagated_result)
|
|
348
|
+
Entities::ServiceAwareEnumerables::LazyEnumerator.new(object: lazy_enumerator, organizer: organizer, propagated_result: propagated_result)
|
|
361
349
|
end
|
|
362
350
|
|
|
363
351
|
##
|
|
364
352
|
# @param chain_enumerator [Enumerator::Chain]
|
|
365
353
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
366
|
-
# @return [ConvenientService::Service::Plugins::
|
|
354
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
367
355
|
#
|
|
368
|
-
def
|
|
369
|
-
Entities::
|
|
356
|
+
def service_aware_chain_enumerator_from(chain_enumerator, propagated_result)
|
|
357
|
+
Entities::ServiceAwareEnumerables::ChainEnumerator.new(object: chain_enumerator, organizer: organizer, propagated_result: propagated_result)
|
|
370
358
|
end
|
|
371
359
|
|
|
372
360
|
##
|
|
373
361
|
# @param arithmetic_sequence_enumerator [Enumerator::ArithmeticSequence]
|
|
374
362
|
# @param propagated_result [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result, nil]
|
|
375
|
-
# @return [ConvenientService::Service::Plugins::
|
|
363
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ArithmeticSequence::Enumerator]
|
|
376
364
|
#
|
|
377
|
-
def
|
|
378
|
-
Entities::
|
|
365
|
+
def service_aware_arithmetic_sequence_enumerator_from(arithmetic_sequence_enumerator, propagated_result)
|
|
366
|
+
Entities::ServiceAwareEnumerables::ArithmeticSequenceEnumerator.new(object: arithmetic_sequence_enumerator, organizer: organizer, propagated_result: propagated_result)
|
|
379
367
|
end
|
|
380
368
|
|
|
381
369
|
##
|
|
@@ -401,16 +389,16 @@ module ConvenientService
|
|
|
401
389
|
|
|
402
390
|
##
|
|
403
391
|
# @param object [Object] Can be any type.
|
|
404
|
-
# @return [ConvenientService::Service::Plugins::
|
|
392
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Base]
|
|
405
393
|
#
|
|
406
|
-
def
|
|
407
|
-
Commands::
|
|
394
|
+
def cast_service_aware_enumerable(object)
|
|
395
|
+
Commands::CastServiceAwareEnumerable.call(object: object, organizer: organizer, propagated_result: propagated_result)
|
|
408
396
|
end
|
|
409
397
|
|
|
410
398
|
##
|
|
411
399
|
# @param value [Symbol, String, Proc, nil]
|
|
412
400
|
# @return [Proc]
|
|
413
|
-
# @raise [ConvenientService::Service::Plugins::
|
|
401
|
+
# @raise [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Exceptions::InvalidEvaluateByValue]
|
|
414
402
|
#
|
|
415
403
|
def cast_evaluate_by_block(value)
|
|
416
404
|
return proc { |enumerable| enumerable.public_send(value) } if value.instance_of?(::Symbol)
|
|
@@ -446,7 +434,7 @@ module ConvenientService
|
|
|
446
434
|
# @param iterator_arguments [ConvenientService::Support::Arguments]
|
|
447
435
|
# @param iterator_block [Proc]
|
|
448
436
|
# @param with_processing_return_value_block [Proc]
|
|
449
|
-
# @return [ConvenientService::Service::Plugins::
|
|
437
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Object]
|
|
450
438
|
#
|
|
451
439
|
# @internal
|
|
452
440
|
# NOTE: `catch` is used to support lazy enumerators, `chunk`, and `chunk_while`.
|
|
@@ -454,7 +442,7 @@ module ConvenientService
|
|
|
454
442
|
def with_processing_return_value(iterator_arguments, iterator_block, &with_processing_return_value_block)
|
|
455
443
|
return yield(Support::UNDEFINED, propagated_result) if propagated_result
|
|
456
444
|
|
|
457
|
-
response = catch(:propagated_result) { {object: iterator_block.call(*iterator_arguments.args, **iterator_arguments.kwargs, &
|
|
445
|
+
response = catch(:propagated_result) { {object: iterator_block.call(*iterator_arguments.args, **iterator_arguments.kwargs, &iterator_arguments.block)} }
|
|
458
446
|
|
|
459
447
|
return yield(Support::UNDEFINED, response[:propagated_result]) if response.has_key?(:propagated_result)
|
|
460
448
|
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
module ConvenientService
|
|
9
9
|
module Service
|
|
10
10
|
module Plugins
|
|
11
|
-
module
|
|
11
|
+
module CanHaveServiceAwareEnumerables
|
|
12
12
|
module Entities
|
|
13
|
-
module
|
|
14
|
-
class Boolean < Entities::
|
|
13
|
+
module ServiceAwareEnumerables
|
|
14
|
+
class Boolean < Entities::ServiceAwareEnumerables::Object
|
|
15
15
|
##
|
|
16
16
|
# @api private
|
|
17
17
|
#
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
module ConvenientService
|
|
9
9
|
module Service
|
|
10
10
|
module Plugins
|
|
11
|
-
module
|
|
11
|
+
module CanHaveServiceAwareEnumerables
|
|
12
12
|
module Entities
|
|
13
|
-
module
|
|
14
|
-
class ChainEnumerator < Entities::
|
|
13
|
+
module ServiceAwareEnumerables
|
|
14
|
+
class ChainEnumerator < Entities::ServiceAwareEnumerables::Enumerator
|
|
15
15
|
##
|
|
16
16
|
# @api private
|
|
17
17
|
#
|
|
@@ -23,12 +23,12 @@ module ConvenientService
|
|
|
23
23
|
# @api public
|
|
24
24
|
#
|
|
25
25
|
# @param iteration_block [Proc, nil]
|
|
26
|
-
# @return [ConvenientService::Service::Plugins::
|
|
26
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
27
27
|
#
|
|
28
28
|
def each(&iteration_block)
|
|
29
29
|
if iteration_block
|
|
30
|
-
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&
|
|
31
|
-
chain_enumerator.each(&
|
|
30
|
+
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&service_aware_iteration_block|
|
|
31
|
+
chain_enumerator.each(&service_aware_iteration_block)
|
|
32
32
|
end
|
|
33
33
|
else
|
|
34
34
|
with_processing_return_value_as_enumerator do
|
|
@@ -42,12 +42,12 @@ module ConvenientService
|
|
|
42
42
|
#
|
|
43
43
|
# @param n [Integer]
|
|
44
44
|
# @param iteration_block [Proc, nil]
|
|
45
|
-
# @return [ConvenientService::Service::Plugins::
|
|
45
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
46
46
|
#
|
|
47
47
|
def each_cons(n, &iteration_block)
|
|
48
48
|
if iteration_block
|
|
49
|
-
with_processing_return_value_as_chain_enumerator(arguments(n, &iteration_block)) do |n, &
|
|
50
|
-
chain_enumerator.each_cons(n, &
|
|
49
|
+
with_processing_return_value_as_chain_enumerator(arguments(n, &iteration_block)) do |n, &service_aware_iteration_block|
|
|
50
|
+
chain_enumerator.each_cons(n, &service_aware_iteration_block)
|
|
51
51
|
end
|
|
52
52
|
else
|
|
53
53
|
with_processing_return_value_as_enumerator(arguments(n)) do |n|
|
|
@@ -60,12 +60,12 @@ module ConvenientService
|
|
|
60
60
|
# @api public
|
|
61
61
|
#
|
|
62
62
|
# @param iteration_block [Proc, nil]
|
|
63
|
-
# @return [ConvenientService::Service::Plugins::
|
|
63
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
64
64
|
#
|
|
65
65
|
def each_entry(&iteration_block)
|
|
66
66
|
if iteration_block
|
|
67
|
-
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&
|
|
68
|
-
chain_enumerator.each_entry(&
|
|
67
|
+
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&service_aware_iteration_block|
|
|
68
|
+
chain_enumerator.each_entry(&service_aware_iteration_block)
|
|
69
69
|
end
|
|
70
70
|
else
|
|
71
71
|
with_processing_return_value_as_enumerator do
|
|
@@ -79,12 +79,12 @@ module ConvenientService
|
|
|
79
79
|
#
|
|
80
80
|
# @param n [Integer]
|
|
81
81
|
# @param iteration_block [Proc, nil]
|
|
82
|
-
# @return [ConvenientService::Service::Plugins::
|
|
82
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
83
83
|
#
|
|
84
84
|
def each_slice(n, &iteration_block)
|
|
85
85
|
if iteration_block
|
|
86
|
-
with_processing_return_value_as_chain_enumerator(arguments(n, &iteration_block)) do |n, &
|
|
87
|
-
chain_enumerator.each_slice(n, &
|
|
86
|
+
with_processing_return_value_as_chain_enumerator(arguments(n, &iteration_block)) do |n, &service_aware_iteration_block|
|
|
87
|
+
chain_enumerator.each_slice(n, &service_aware_iteration_block)
|
|
88
88
|
end
|
|
89
89
|
else
|
|
90
90
|
with_processing_return_value_as_enumerator(arguments(n)) do |n|
|
|
@@ -97,12 +97,12 @@ module ConvenientService
|
|
|
97
97
|
# @api public
|
|
98
98
|
#
|
|
99
99
|
# @param iteration_block [Proc, nil]
|
|
100
|
-
# @return [ConvenientService::Service::Plugins::
|
|
100
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
101
101
|
#
|
|
102
102
|
def each_with_index(&iteration_block)
|
|
103
103
|
if iteration_block
|
|
104
|
-
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&
|
|
105
|
-
chain_enumerator.each_with_index(&
|
|
104
|
+
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&service_aware_iteration_block|
|
|
105
|
+
chain_enumerator.each_with_index(&service_aware_iteration_block)
|
|
106
106
|
end
|
|
107
107
|
else
|
|
108
108
|
with_processing_return_value_as_enumerator do
|
|
@@ -115,12 +115,12 @@ module ConvenientService
|
|
|
115
115
|
# @api public
|
|
116
116
|
#
|
|
117
117
|
# @param iteration_block [Proc, nil]
|
|
118
|
-
# @return [ConvenientService::Service::Plugins::
|
|
118
|
+
# @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator, ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::ChainEnumerator]
|
|
119
119
|
#
|
|
120
120
|
def reverse_each(&iteration_block)
|
|
121
121
|
if iteration_block
|
|
122
|
-
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&
|
|
123
|
-
chain_enumerator.reverse_each(&
|
|
122
|
+
with_processing_return_value_as_chain_enumerator(arguments(&iteration_block)) do |&service_aware_iteration_block|
|
|
123
|
+
chain_enumerator.reverse_each(&service_aware_iteration_block)
|
|
124
124
|
end
|
|
125
125
|
else
|
|
126
126
|
with_processing_return_value_as_enumerator do
|