Sha256: 1df81ebb261b1eef0cbfa06b085b0ce441dbad5ad94e979de43bc906e9c5dea2
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
module GlipSdk::REST::Cache class Groups attr_accessor :groups attr_accessor :groups_name2id attr_accessor :teams attr_accessor :teams_name2id def initialize @groups = {} @teams = {} @teams_name2id = {} @groups_name2id = {} end 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 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 def id_by_name(name) group = by_name name group.nil? ? nil : group['id'] end def by_name(name) team = team_by_name name return team unless team.nil? group_by_name name end def team_by_name(name) team_id = @teams_name2id[name.to_s] team_id ? @teams[team_id] : nil end def group_by_name(name) group_id = @groups_name2id[name.to_s] group_id ? @groups[group_id] : nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
glip_sdk-0.0.5 | lib/glip_sdk/rest/cache/groups.rb |
glip_sdk-0.0.4 | lib/glip_sdk/rest/cache/groups.rb |
glip_sdk-0.0.3 | lib/glip_sdk/rest/cache/groups.rb |