Class: GlipSdk::REST::Cache::Groups

Inherits:
Object
  • Object
show all
Defined in:
lib/glip_sdk/rest/cache/groups.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGroups

Returns a new instance of Groups.



7
8
9
10
11
12
# File 'lib/glip_sdk/rest/cache/groups.rb', line 7

def initialize
  @groups = {}
  @teams = {}
  @teams_name2id = {}
  @groups_name2id = {}
end

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



3
4
5
# File 'lib/glip_sdk/rest/cache/groups.rb', line 3

def groups
  @groups
end

#groups_name2idObject

Returns the value of attribute groups_name2id.



4
5
6
# File 'lib/glip_sdk/rest/cache/groups.rb', line 4

def groups_name2id
  @groups_name2id
end

#teamsObject

Returns the value of attribute teams.



5
6
7
# File 'lib/glip_sdk/rest/cache/groups.rb', line 5

def teams
  @teams
end

#teams_name2idObject

Returns the value of attribute teams_name2id.



6
7
8
# File 'lib/glip_sdk/rest/cache/groups.rb', line 6

def teams_name2id
  @teams_name2id
end

Instance Method Details

#load_group(group) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/glip_sdk/rest/cache/groups.rb', line 18

def load_group(group)
  if group.key? 'id'
    id = group['id']
    type = group['type']
    if type.to_s.downcase == 'team'
      @teams[id.to_s] = group
      @teams_name2id[group['name']] = id.to_s
    else
      @groups[id.to_s] = group
      @groups_name2id[group['name']] = id.to_s
    end
  end
end

#load_groups(groups) ⇒ Object



14
15
16
# File 'lib/glip_sdk/rest/cache/groups.rb', line 14

def load_groups(groups)
  groups.each { |g| load_group g }
end

#team_by_name(name) ⇒ Object



32
33
34
35
# File 'lib/glip_sdk/rest/cache/groups.rb', line 32

def team_by_name(name)
  # Innovation & Ops Extended Staff
  @teams[name.to_s]
end