Sha256: ec8821218a7e77aaba60687252a38f393d061df0fe3eb961e4644ffe540d6628

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module Conjur
  module DSL2
    class Plan
      attr_reader :actions, :policy, :roles_created, :resources_created
      attr_accessor :namespace, :ownerid

      
      def initialize namespace = nil
        @namespace = namespace
        @actions = []
        @policy = nil
        @roles_created = Set.new
        @resources_created = Set.new
      end
      
      def scoped_id id
        id = id.id if id.respond_to?(:id)

        # id is nil means it should have the same id as the policy
        id = '' if id.nil?

        if id[0] == '/'
          id[1..-1]
        else

          tokens = []
          tokens.push @namespace if @namespace
          tokens.push @policy.id if @policy

          if id.start_with?(tokens.join('/') + '/')
            id
          else
            tokens.push id unless id.empty?
            tokens.join('/')
          end
        end
      end
      
      def policy= policy
        raise "Plan policy is already specified" if @policy && policy
        @policy = policy
      end
      
      def action a
        @actions.push a
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
conjur-asset-dsl2-0.4.4 lib/conjur/dsl2/plan.rb
conjur-asset-dsl2-0.4.3 lib/conjur/dsl2/plan.rb
conjur-asset-dsl2-0.4.2 lib/conjur/dsl2/plan.rb
conjur-asset-dsl2-0.3.2 lib/conjur/dsl2/plan.rb
conjur-asset-dsl2-0.3.1 lib/conjur/dsl2/plan.rb
conjur-asset-dsl2-0.3.0 lib/conjur/dsl2/plan.rb