lib/eco/api/session/batch/job.rb in eco-helpers-2.6.0 vs lib/eco/api/session/batch/job.rb in eco-helpers-2.6.1

- old
+ new

@@ -7,10 +7,12 @@ # @attr_reader sets [Array<Symbol>] the parts of the person model this batch is supposed to affect # @attr_reader usecase [Eco::API::UseCases::UseCase, nil] when provided: `usecase` that generated this `batch job` # @attr_reader status [Eco::API::Session::Batch::Status] if launched: the `status` of the `batch` # @attr_reader feedback [Eco::API::Session::Batch::Feedback] helper class for feedback and end-user decision making class Job < Eco::API::Common::Session::BaseSession + include Eco::Language::Methods::DslAble + @types = [:get, :create, :update, :delete] @sets = [:core, :details, :account] class << self attr_reader :types, :sets @@ -276,17 +278,18 @@ # and the current batch is not a creation batch # - filter out excluded entries from the api update def api_included(full_queue) return full_queue if type == :create return full_queue unless excluded_callback = session.config.people.api_excluded - excluded = options.dig(:include, :excluded) - if excluded.is_a?(Hash) && excluded[:only] - full_queue.select {|entry| excluded_callback.call(entry, session, options, self)} - elsif options.dig(:include, :excluded) - full_queue - else - full_queue.select {|entry| !excluded_callback.call(entry, session, options, self)} + + inc_excluded = options.dig(:include, :excluded) + excluded_only = inc_excluded.is_a?(Hash) && excluded[:only] + is_excluded = Proc.new do |entry| + evaluate(entry, session, options, self, &excluded_callback) end + return full_queue.select(&is_excluded) if excluded_only + return full_queue if inc_excluded + full_queue.reject(&is_excluded) end # Applies the changes introduced by api policies def apply_policies(pre_queue) people(pre_queue).tap do |entries|