Class: Fog::Parsers::AWS::IAM::ListManagedPolicies

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

Instance Method Summary collapse

Methods inherited from PolicyParser

#fresh_policy

Instance Method Details

#end_element(name) ⇒ Object



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

def end_element(name)
  case name
  when 'RequestId', 'Marker'
    @response[name] = value
  when 'IsTruncated'
    @response[name] = (value == 'true')
  when 'PolicyArn', 'PolicyName'
    @policy[name] = value
  when 'AttachedPolicies'
    if @stack.last == 'AttachedPolicies'
      @stack.pop
    end
  when 'member'
    if @stack.last == 'AttachedPolicies'
      finished_policy(@policy)
      @policy = nil
    end
  end
  super
end

#finished_policy(policy) ⇒ Object



13
14
15
# File 'lib/fog/aws/parsers/iam/list_managed_policies.rb', line 13

def finished_policy(policy)
  @response['Policies'] << policy
end

#resetObject



8
9
10
11
# File 'lib/fog/aws/parsers/iam/list_managed_policies.rb', line 8

def reset
  super
  @response = { 'Policies' => [] , 'Marker' => '', 'IsTruncated' => false}
end

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



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aws/parsers/iam/list_managed_policies.rb', line 17

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