Sha256: b5f369c1e412fefbc09bfa57e46158e5c17f3d735ca92d584e44dfb0e77a325d

Contents?: true

Size: 1022 Bytes

Versions: 5

Compression:

Stored size: 1022 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

5 entries across 5 versions & 1 rubygems

Version Path
conjur-asset-policy-0.8.3 lib/conjur/policy/planner.rb
conjur-asset-policy-0.8.2 lib/conjur/policy/planner.rb
conjur-asset-policy-0.8.1 lib/conjur/policy/planner.rb
conjur-asset-policy-0.8.0 lib/conjur/policy/planner.rb
conjur-asset-policy-0.7.1 lib/conjur/policy/planner.rb