Sha256: 63a38c973f4ba5ec3f7db6fdb12072136a5c08de725d251d651c17bde6c827c6

Contents?: true

Size: 1.13 KB

Versions: 136

Compression:

Stored size: 1.13 KB

Contents

module Eco
  module API
    # @todo the autoloading happens on `add`, and there could be multiple pending children to load.
    #   This could translate into the policies not being loaded in order
    class Policies < Eco::API::UseCases
      autoloads_children_of "Eco::API::Common::Loaders::Policy"
      autoload_namespace_ignore "Eco::API"

      attr_reader :policies

      def define(name, type: :transform, &block)
        Eco::API::Policies::Policy.new(name, type: type, root: self, &block).tap do |policy|
          add(policy)
        end
      end

      def add(policy)
        raise "Expected Eco::API::Policies::Policy object. Given: #{policy}" unless policy.is_a?(Eco::API::Policies::Policy)
        super(policy)
      end

      def launch(people:, session:, job:, options: {})
        args = {
          people:  people,
          session: session,
          job:     job,
          options: options
        }

        items.map do |policy|
          policy.launch(**args)
        end
      end
    end
  end
end

require_relative 'policies/policy'
require_relative 'policies/default_policies'

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
eco-helpers-2.0.15 lib/eco/api/policies.rb
eco-helpers-2.0.14 lib/eco/api/policies.rb
eco-helpers-2.0.13 lib/eco/api/policies.rb
eco-helpers-2.0.12 lib/eco/api/policies.rb
eco-helpers-2.0.11 lib/eco/api/policies.rb
eco-helpers-2.0.10 lib/eco/api/policies.rb
eco-helpers-2.0.9 lib/eco/api/policies.rb
eco-helpers-2.0.8 lib/eco/api/policies.rb
eco-helpers-2.0.7 lib/eco/api/policies.rb
eco-helpers-2.0.6 lib/eco/api/policies.rb
eco-helpers-2.0.5 lib/eco/api/policies.rb
eco-helpers-2.0.4 lib/eco/api/policies.rb
eco-helpers-2.0.3 lib/eco/api/policies.rb
eco-helpers-2.0.2 lib/eco/api/policies.rb
eco-helpers-1.5.15 lib/eco/api/policies.rb
eco-helpers-1.5.14 lib/eco/api/policies.rb