Sha256: 0c981c47f86491e11862be6c397830c6f2c837c8bc4f38a5884b196f41477edb

Contents?: true

Size: 1014 Bytes

Versions: 3

Compression:

Stored size: 1014 Bytes

Contents

require 'conjur/policy/plan'
require 'conjur/policy/planner/record'
require 'conjur/policy/planner/permissions'
require 'conjur/policy/planner/grants'

module Conjur
  module Policy
    module Planner
      class << self
        def plan records, api, plan = nil
          plan ||= Plan.new
          plan.tap do |plan|
            Array(records).map{ |record| planner_for(record, api) }.each do |planner|
              planner.plan = plan
              planner.log { %Q(Planning "#{planner.record} using #{planner.class}") }
              begin
                planner.do_plan
                planner.log { "\tFinished \"#{planner.record}\"" }
              ensure
                planner.plan = nil
              end
            end
          end
        end
        
        def planner_for record, api
          cls = begin
            const_get record.class.name.split("::")[-1]
          rescue NameError
            Record
          end
          cls.new record, api
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conjur-asset-policy-0.13.0 lib/conjur/policy/planner.rb
conjur-asset-policy-0.12.0 lib/conjur/policy/planner.rb
conjur-asset-policy-0.11.0 lib/conjur/policy/planner.rb