module Eco module API module Policies class UsedPolicies < Eco::API::UseCases::UseGroup attr_reader :policies def add(policy) raise "Expected Policy object. Given: #{policy}" if !policy || !policy.is_a?(Policy) super(policy) end def define(name, type: :transform, &block) Policy.new(name, type: type, root: self, &block).tap do |policy| add(policy) end end # TODO: decide if policies deal with queue or single person def launch(people:, session:, options: {}) args = { people: people, session: session, options: options } items.map do |policy| session.logger.debug("UsedPolicies: going to process '#{policy.name}' policy") policy.launch(**args) end end end end end end