class GlipSdk::REST::Cache::Groups
Attributes
groups[RW]
groups_name2id[RW]
teams[RW]
teams_name2id[RW]
Public Class Methods
new()
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 7 def initialize @groups = {} @teams = {} @teams_name2id = {} @groups_name2id = {} end
Public Instance Methods
by_name(name)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 41 def by_name(name) team = team_by_name name return team unless team.nil? group_by_name name end
group_by_name(name)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 52 def group_by_name(name) group_id = @groups_name2id[name.to_s] group_id ? @groups[group_id] : nil end
id_by_name(name)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 36 def id_by_name(name) group = by_name name group.nil? ? nil : group['id'] end
load_group(group)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 22 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)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 14 def load_groups(groups) if groups.is_a? Array groups.each { |g| load_group g } elsif groups.is_a? Hash groups.each { |_, g| load_group g} end end
team_by_name(name)
click to toggle source
# File lib/glip_sdk/rest/cache/groups.rb, line 47 def team_by_name(name) team_id = @teams_name2id[name.to_s] team_id ? @teams[team_id] : nil end