Class: Goz::Group::Grouper::StemmedGroups
- Inherits:
-
Goz::Group::Grouper
- Object
- Base
- Goz::Group::Grouper
- Goz::Group::Grouper::StemmedGroups
- Defined in:
- lib/goz/group/grouper/stemmed_groups.rb
Overview
Goz::Group::Grouper::StemmedGroups - TODO
Usage
TODO
Author
blair christensen. <[email protected]>
Homepage
Constant Summary collapse
- TAG =
self.name
Instance Attribute Summary
Attributes inherited from Base
#display_name, #identifier, #klass, #name
Class Method Summary collapse
-
.find_by_name(name) ⇒ Object
Find Goz::Group by name or return
nil
. -
.groups(user) ⇒ Object
Return groups where
user
is an admin. -
.memberships(user) ⇒ Object
Return groups where
user
is a member.
Instance Method Summary collapse
-
#admins ⇒ Object
TODO.
-
#initialize(g) ⇒ StemmedGroups
constructor
TODO.
-
#members ⇒ Object
TODO.
-
#stem?(name) ⇒ Boolean
TODO.
Methods inherited from Goz::Group::Grouper
extension, stem, stemmed_group?
Methods inherited from Base
#[], configuration, #to_hash, #to_s
Constructor Details
#initialize(g) ⇒ StemmedGroups
TODO
34 35 36 37 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 34 def initialize(g) super(g) @klass = self.class.name end |
Class Method Details
.find_by_name(name) ⇒ Object
Find Goz::Group by name or return nil
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 42 def self.find_by_name(name) name.rstrip! Goz::Logger.debug TAG, "find_by_name( name=#{name} )" g = super(name) return g unless g.nil? connect do |grouper| ns = grouper.stem(name) if ns.nil? Goz::Logger.debug TAG, "find_by_name( name=#{name} ) - not found" return nil end return new ns end nil end |
.groups(user) ⇒ Object
Return groups where user
is an admin.
71 72 73 74 75 76 77 78 79 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 71 def self.groups(user) Goz::Logger.debug TAG, "groups( user.login=#{user.login} )" groups = [] memberships(user).each do |g| groups << g if stemmed_group?(g.name) && @@cf['admin_suffix'].include?( extension(g.name) ) end groups.each { |g| yield g } if block_given? groups end |
.memberships(user) ⇒ Object
Return groups where user
is a member.
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 93 def self.memberships(user) Goz::Logger.debug TAG, "memberships( user.login=#{user.login} )" groups = [] super(user).each do |g| g.klass = self.name groups << g groups << find_by_name( stem(g.name) ) if stemmed_group?(g.name) end groups.each { |g| yield g } if block_given? groups end |
Instance Method Details
#admins ⇒ Object
TODO
61 62 63 64 65 66 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 61 def admins() Goz::Logger.debug TAG, "name=#{self.name} - #admins()" return super unless stem?(self.name) return super if self.class.stemmed_group?(self.name) _members @@cf['admin_suffix'] end |
#members ⇒ Object
TODO
84 85 86 87 88 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 84 def members() Goz::Logger.debug TAG, "#{self.name} - #members()" return super unless stem?(self.name) _members @@cf['member_suffix'] end |
#stem?(name) ⇒ Boolean
TODO
108 109 110 111 112 |
# File 'lib/goz/group/grouper/stemmed_groups.rb', line 108 def stem?(name) self.class.connect do |grouper| return grouper.stem(name) ? true : false end end |