Class: PolicyDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/cfn-model/model/policy_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolicyDocument

Returns a new instance of PolicyDocument.



8
9
10
# File 'lib/cfn-model/model/policy_document.rb', line 8

def initialize
  @statements = []
end

Instance Attribute Details

#statementsObject

Returns the value of attribute statements.



6
7
8
# File 'lib/cfn-model/model/policy_document.rb', line 6

def statements
  @statements
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/cfn-model/model/policy_document.rb', line 6

def version
  @version
end

Instance Method Details

#==(another_doc) ⇒ Object



39
40
41
# File 'lib/cfn-model/model/policy_document.rb', line 39

def ==(another_doc)
  self.version == another_doc.version && @statements == another_doc.statements
end

#allows_not_actionObject

Select any Statement objects that Allow in conjunction with a NotAction



27
28
29
# File 'lib/cfn-model/model/policy_document.rb', line 27

def allows_not_action
  @statements.select { |statement| !statement.not_actions.empty? && statement.effect == 'Allow' }
end

#allows_not_principalObject



35
36
37
# File 'lib/cfn-model/model/policy_document.rb', line 35

def allows_not_principal
  @statements.select { |statement| !statement.not_principal.nil? && statement.effect == 'Allow' }
end

#allows_not_resourceObject



31
32
33
# File 'lib/cfn-model/model/policy_document.rb', line 31

def allows_not_resource
  @statements.select { |statement| !statement.not_resources.empty? && statement.effect == 'Allow' }
end

#to_sObject



43
44
45
46
47
48
49
50
# File 'lib/cfn-model/model/policy_document.rb', line 43

def to_s
  <<END
{
version=#{@version}
statements=#{@statements}
}
END
end

#wildcard_allowed_actionsObject



16
17
18
# File 'lib/cfn-model/model/policy_document.rb', line 16

def wildcard_allowed_actions
  @statements.select { |statement| !statement.wildcard_actions.empty? && statement.effect == 'Allow' }
end

#wildcard_allowed_principalsObject



20
21
22
# File 'lib/cfn-model/model/policy_document.rb', line 20

def wildcard_allowed_principals
  @statements.select { |statement| statement.wildcard_principal? && statement.effect == 'Allow' }
end

#wildcard_allowed_resourcesObject



12
13
14
# File 'lib/cfn-model/model/policy_document.rb', line 12

def wildcard_allowed_resources
  @statements.select { |statement| !statement.wildcard_resources.empty? && statement.effect == 'Allow' }
end