Sha256: aff121887ce7478fec19f4a1a451ecf1f1dc46c4c9474a06d30ccc24d47e521e

Contents?: true

Size: 791 Bytes

Versions: 33

Compression:

Stored size: 791 Bytes

Contents

module Eco
  module API
    class Policies < Eco::API::UseCases
      attr_reader :policies

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

      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 launch(people:, session:, options: {})

        args = {
          people:  people,
          session: session,
          options: options
        }

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

require_relative 'policies/policy'

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
eco-helpers-1.3.7 lib/eco/api/policies.rb
eco-helpers-1.3.6 lib/eco/api/policies.rb
eco-helpers-1.3.5 lib/eco/api/policies.rb
eco-helpers-1.3.4 lib/eco/api/policies.rb
eco-helpers-1.3.3 lib/eco/api/policies.rb
eco-helpers-1.3.2 lib/eco/api/policies.rb
eco-helpers-1.3.1 lib/eco/api/policies.rb
eco-helpers-1.2.2 lib/eco/api/policies.rb
eco-helpers-1.2.1 lib/eco/api/policies.rb
eco-helpers-1.1.8 lib/eco/api/policies.rb
eco-helpers-1.1.7 lib/eco/api/policies.rb
eco-helpers-1.1.6 lib/eco/api/policies.rb
eco-helpers-1.1.5 lib/eco/api/policies.rb
eco-helpers-1.1.4 lib/eco/api/policies.rb
eco-helpers-1.1.3 lib/eco/api/policies.rb
eco-helpers-1.1.2 lib/eco/api/policies.rb
eco-helpers-1.1.1 lib/eco/api/policies.rb
eco-helpers-1.0.14 lib/eco/api/policies.rb
eco-helpers-1.0.13 lib/eco/api/policies.rb
eco-helpers-1.0.12 lib/eco/api/policies.rb