Skip to content

Commit 9dea411

Browse files
committed
yay, remove old code, it's super simple now.
1 parent 7a2e6d3 commit 9dea411

1 file changed

Lines changed: 0 additions & 91 deletions

File tree

lib/trailblazer/macro/each.rb

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ def self.call((ctx, flow_options), runner:, **circuit_options)
8787
}
8888
end
8989

90-
91-
9290
class Each < Macro::Strategy
9391
# FIXME: for Strategy that wants to pass-through the {:exec_context}, so it
9492
# looks "invisible" for steps.
@@ -135,95 +133,6 @@ def self.compute_runtime_id(ctx, trace_node:, activity:, compile_id:, **)
135133
ctx[:runtime_id] = "#{compile_id}.#{index}"
136134
end
137135
end
138-
139-
# @api private The internals here are considered private and might change in the near future.
140-
def self.Each__FIXME(block_activity=nil, dataset_from: nil, item_key: :item, id: Macro.id_for(block_activity, macro: :Each, hint: dataset_from), collect: false, **dsl_options_for_iterated, &block)
141-
dsl_options_for_iterated = block_activity if block_activity.is_a?(Hash) # Ruby 2.5 and 2.6
142-
143-
block_activity, outputs_from_block_activity = Macro.block_activity_for(block_activity, &block)
144-
145-
collect_options = options_for_collect(collect: collect)
146-
dataset_from_options = options_for_dataset_from(dataset_from: dataset_from)
147-
148-
wrap_static_for_block_activity = task_wrap_for_iterated(
149-
{Activity::Railway.Out() => []}. # per default, don't let anything out.
150-
merge(collect_options).
151-
merge(dsl_options_for_iterated)
152-
)
153-
154-
# This activity is passed into the {Runner} for each iteration of {block_activity}.
155-
container_activity = Activity::TaskWrap.container_activity_for(
156-
block_activity,
157-
id: "invoke_block_activity",
158-
# merged into {:config}:
159-
each: true, # mark this activity for {compute_runtime_id}.
160-
).merge(
161-
outputs: outputs_from_block_activity,
162-
fields: {task_wrap_extensions: Activity::DSL::Linear::Strategy::INITIAL_TASK_WRAP_EXTENSIONS} # DISCUSS: shouldn't this be part of {:config}? # FIXME: too much knowledge about internals.
163-
)
164-
165-
# FIXME: we can't pass {wrap_static: wrap_static_for_block_activity} into {#container_activity_for}
166-
# because when patching, the container_activity is not recompiled, so we need the Hash here
167-
# with defaulting.
168-
# FIXME: this "hack" is only here to satify patching.
169-
config = container_activity[:config].merge(wrap_static: Hash.new(wrap_static_for_block_activity))
170-
container_activity.merge!(config: config)
171-
172-
# DISCUSS: move to Wrap.
173-
termini_from_block_activity =
174-
outputs_from_block_activity.
175-
# DISCUSS: End.success needs to be the last here, so it's directly behind {Start.default}.
176-
sort { |a,b| a.semantic == :success ? 1 : -1 }.
177-
collect { |output|
178-
[output.signal, id: "End.#{output.semantic}", magnetic_to: output.semantic, append_to: "Start.default"]
179-
}
180-
181-
state = Declarative::State(
182-
block_activity: [block_activity, {copy: Trailblazer::Declarative::State.method(:subclass)}], # DISCUSS: move to Macro::Strategy.
183-
item_key: [item_key, {}], # DISCUSS: we could even allow the wrap_handler to be patchable.
184-
failing_semantic: [[:failure, :fail_fast], {}],
185-
activity: [container_activity, {}],
186-
success_signal: [termini_from_block_activity[-1][0], {}] # FIXME: when subclassing (e.g. patching) this must be recomputed.
187-
)
188-
189-
# |-- Each/composers_for_each
190-
# | |-- Start.default
191-
# | |-- Each.iterate.block This is Class.new(Each), outputs_from_block_activity
192-
# | | |-- invoke_block_activity.0 step :invoke_block_activity.0
193-
# | | | |-- Start.default
194-
# | | | |-- notify_composers
195-
# | | | `-- End.success
196-
# | | `-- invoke_block_activity.1 step "invoke_block_activity.1"
197-
# | | |-- Start.default
198-
# | | |-- notify_composers
199-
iterate_strategy = Class.new(Each) do
200-
extend Macro::Strategy::State # now, the Wrap subclass can inherit its state and copy the {block_activity}.
201-
initialize!(state)
202-
end
203-
204-
each_activity = Activity::FastTrack(termini: termini_from_block_activity) # DISCUSS: what base class should we be using?
205-
each_activity.extend Each::Transitive
206-
207-
# {Subprocess} with {strict: true} will automatically wire all {block_activity}'s termini to the corresponding termini
208-
# of {each_activity} as they have the same semantics (both termini sets are identical).
209-
each_activity.step Activity::Railway.Subprocess(iterate_strategy, strict: true),
210-
id: "Each.iterate.#{block ? :block : block_activity}" # FIXME: test :id.
211-
212-
Activity::Railway.Subprocess(each_activity).
213-
merge(id: id).
214-
merge(dataset_from_options) # FIXME: provide that service via Subprocess.
215-
end
216-
217-
def self.task_wrap_for_iterated(dsl_options)
218-
# TODO: maybe the DSL API could be more "open" here? I bet it is, but I'm too lazy.
219-
activity = Class.new(Activity::Railway) do
220-
step({task: "iterated"}.merge(dsl_options))
221-
end
222-
223-
activity.to_h[:config][:wrap_static]["iterated"]
224-
end
225-
226-
227136
end
228137

229138
if const_defined?(:Developer) # FIXME: how do you properly check for a gem?

0 commit comments

Comments
 (0)