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.



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

def initialize
  @statements = []
end

Instance Attribute Details

#statementsObject

Returns the value of attribute statements.



4
5
6
# File 'lib/cfn-model/model/policy_document.rb', line 4

def statements
  @statements
end

#versionObject

Returns the value of attribute version.



4
5
6
# File 'lib/cfn-model/model/policy_document.rb', line 4

def version
  @version
end

Instance Method Details

#==(another_doc) ⇒ Object



37
38
39
# File 'lib/cfn-model/model/policy_document.rb', line 37

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



25
26
27
# File 'lib/cfn-model/model/policy_document.rb', line 25

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

#allows_not_principalObject



33
34
35
# File 'lib/cfn-model/model/policy_document.rb', line 33

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

#allows_not_resourceObject



29
30
31
# File 'lib/cfn-model/model/policy_document.rb', line 29

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

#to_sObject



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

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

#wildcard_allowed_actionsObject



14
15
16
# File 'lib/cfn-model/model/policy_document.rb', line 14

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

#wildcard_allowed_principalsObject



18
19
20
# File 'lib/cfn-model/model/policy_document.rb', line 18

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

#wildcard_allowed_resourcesObject



10
11
12
# File 'lib/cfn-model/model/policy_document.rb', line 10

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