Sha256: 8f1c2531f0d04247dbbbdbdc16449c6e8aa025745e37e744e9ba40d8d2fadfc7

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 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, options = {}
          namespace = options[:namespace]
          ownerid   = options[:ownerid]
          Plan.new.tap do |plan|
            plan.namespace = namespace if namespace
            plan.ownerid = ownerid if ownerid
            records.map{ |record| planner_for(record, api) }.sort.each do |planner|
              planner.plan = plan
              begin
                planner.do_plan
              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

4 entries across 4 versions & 1 rubygems

Version Path
conjur-asset-dsl2-0.4.2 lib/conjur/dsl2/planner.rb
conjur-asset-dsl2-0.3.2 lib/conjur/dsl2/planner.rb
conjur-asset-dsl2-0.3.1 lib/conjur/dsl2/planner.rb
conjur-asset-dsl2-0.3.0 lib/conjur/dsl2/planner.rb