Class: Fog::Parsers::AWS::IAM::PolicyParser

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/iam/policy_parser.rb

Direct Known Subclasses

ListManagedPolicies, SinglePolicy

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/aws/parsers/iam/policy_parser.rb', line 29

def end_element(name)
  case name
  when 'Arn', 'DefaultVersionId', 'Description', 'Path', 'PolicyName', 'PolicyId'
    @policy[name] = value
  when 'CreateDate', 'UpdateDate'
    @policy[name] = Time.parse(value)
  when 'IsAttachable'
    @policy[name] = (value == 'true')
  when 'AttachmentCount'
    @policy[name] = value.to_i
  when 'Policy'
    finished_policy(@policy)
    @policy = nil
  when 'Policies'
    if @stack.last == 'Policies'
      @stack.pop
    end
  when 'member'
    if @stack.last == 'Policies'
      finished_policy(@policy)
      @policy = nil
    end
  end
end

#fresh_policyObject



25
26
27
# File 'lib/fog/aws/parsers/iam/policy_parser.rb', line 25

def fresh_policy
  {'AttachmentCount' => 0, 'Description' => ''}
end

#resetObject



6
7
8
9
# File 'lib/fog/aws/parsers/iam/policy_parser.rb', line 6

def reset
  @policy = fresh_policy
  @stack = []
end

#start_element(name, attrs = []) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws/parsers/iam/policy_parser.rb', line 11

def start_element(name,attrs = [])
  case name
  when 'Policies'
    @stack << name
  when 'Policy'
    @policy = fresh_policy
  when 'member'
    if @stack.last == 'Policies'
      @policy = fresh_policy
    end
  end
  super
end