class Eco::API::UseCases::GraphQL::Samples::Location module Command::DSL include Eco::API::UseCases::GraphQL::Helpers::Location::Command include Eco::API::UseCases::GraphQL::Samples::Location::Command::Results # @example of implementation: # def inputs(command_types, force_continue: force_continue?) # {}.tap do |sequence| # command_types.commands do |comms, stage| # sequence[stage] = input(comms, force_continue: force_continue) # end # end.tap do |sequence| # sequence.each do |stage, input| # yield(input, stage) if block_given? # end # end # end def inputs(*args, force_continue: force_continue?, **kargs, &block) msg = "You should implement this method in your child class.\n" msg << "Which should yield the input Hash and the stage or descriptor." raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg end # Main processor def process begin super if defined?(super) rescue Eco::API::UseCases::GraphQL::Base::NotImplementedMethod end self.error = false # this triggers a backup of the tagtree self.current_tree ||= live_tree inputs(force_continue: force_continue?) do |input, stage| results[stage] ||= [] sliced_batches(input, desc: stage) do |sliced_input, response, page, pages, done, total| track_current_tree(response&.structure) page_results = nil results[stage] << (page_results = request_results_class.new(sliced_input, response)) update_tags_remap_table(page_results, stage) break if self.error = page_errors?(page_results, page, pages, done, total, stage: stage) end break if error end rescue StandardError => e log(:error) { self.exception ||= e.patch_full_message } raise ensure rescued { self.tags_remap_csv_file = generate_tags_remap_csv } end end end