Class: CloudParty::Responses::Node::Permissions

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_party/responses/nodes/zones/permissions.rb,
lib/cloud_party/responses/nodes/memberships/permissions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsh) ⇒ Permissions

Returns a new instance of Permissions.



7
8
9
10
11
12
13
14
# File 'lib/cloud_party/responses/nodes/zones/permissions.rb', line 7

def initialize(array)
  @perms = {}
  array.each do |perm|
    perm_obj = parse_perm(perm)
    @perms[perm_obj[:perm_name]] ||= []
    @perms[perm_obj[:perm_name]] << perm_obj[:perm_value]
  end
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



16
17
18
# File 'lib/cloud_party/responses/nodes/memberships/permissions.rb', line 16

def list
  @list
end

#permsObject (readonly)

Returns the value of attribute perms.



21
22
23
# File 'lib/cloud_party/responses/nodes/zones/permissions.rb', line 21

def perms
  @perms
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/cloud_party/responses/nodes/zones/permissions.rb', line 27

def inspect
  to_s
end

#parse_perm(perm) ⇒ Object



16
17
18
19
# File 'lib/cloud_party/responses/nodes/zones/permissions.rb', line 16

def parse_perm(perm)
  pattern = /\#(?<perm_name>.+):(?<perm_value>.+)/
  pattern.match(perm)
end

#to_sObject



23
24
25
# File 'lib/cloud_party/responses/nodes/zones/permissions.rb', line 23

def to_s
  "#<Permissions: #{perms}>"
end