Sha256: d7c32356cb96407f88246e570ad6b59ea896581ec28cd7c62924e5364e7f2bbf

Contents?: true

Size: 1012 Bytes

Versions: 3

Compression:

Stored size: 1012 Bytes

Contents

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

module Conjur
  module DSL2
    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-dsl2-0.6.1 lib/conjur/dsl2/planner.rb
conjur-asset-dsl2-0.6.0 lib/conjur/dsl2/planner.rb
conjur-asset-dsl2-0.5.0 lib/conjur/dsl2/planner.rb