Class PeerGroup
In: app/models/peer_group.rb
Parent: ActiveRecord::Base

The Philosophy of PeerGroups

Things look quite different from different perspectives. PeerGroups model this difference between - what in philosophy are also called - Paradigms, Discourses, or Language Games.

Everyone can become a member of any PeerGroup. But one can only get (more) voting- power within it if one‘s own work is rated well by other members of the same PeerGroup. In this way PeerGroups can admin and steer themselves.

Also every user is allowed to create new PeerGroups.

Thus we allow a combination between freedom and quality-control.

The Technology of Peergoups

Users are members of PeerGroups through PeerGroupMemberships.

Ratings are made by Users within a PeerGroup.

Methods

Included Modules

HomePageModule UnixNameModule

Attributes

admin  [W] 

Public Class methods

Returns the public peer_group.

[Source]

    # File app/models/peer_group.rb, line 80
80:   def self.public
81:     return GlobalConfig.public_peer_group
82:   end

Returns UsedTags for the PeerGroups with most members for the tag-cloud.

Arguments:

  • limit = the max amount of tags returned

[Source]

    # File app/models/peer_group.rb, line 91
91:   def self.top_peer_groups(options = {})
92:     return PeerGroup.find(:all, options.merge(:order => "memberships_count DESC")).sort_by {|group| group.name}
93:   end

Public Instance methods

Returns the admin-user of this PeerGroup.

[Source]

     # File app/models/peer_group.rb, line 131
131:   def admin
132:     self.admin_membership.user
133:   end

Returns the membership of the admin of this PeerGroup.

[Source]

     # File app/models/peer_group.rb, line 137
137:   def admin_membership
138:     self.memberships.find_by_role(Const::PeerGroupMembership::ADMIN)
139:   end

Checks if the given user has the admin-role.

[Source]

     # File app/models/peer_group.rb, line 125
125:   def admin_permissions?(user)
126:     user == self.admin or user.admin?
127:   end

Returns the link to the peer groups homepage.

[Source]

     # File app/models/peer_group.rb, line 143
143:   def home_page_link
144:     return self.home_page_link_for(Tag.peer_group)
145:   end

Returns the membership of this PeerGroup for the given user.

If it doesn‘t exist yet it is built.

[Source]

     # File app/models/peer_group.rb, line 115
115:   def membership_for(user)
116:     membership = self.memberships.find_by_user_id(user.id)
117:     if membership.nil?
118:       membership = self.memberships.build(:user => user)
119:     end
120:     return membership
121:   end

Returns true if this UserGroup is the public usergroup

[Source]

     # File app/models/peer_group.rb, line 107
107:   def public?
108:     return self == PeerGroup.public
109:   end

Returns a short version of the name.

[Source]

     # File app/models/peer_group.rb, line 149
149:   def short_name
150:     if self.name.size > 30
151:       return self.name[0..28] + '..'
152:     else
153:       return self.name
154:     end
155:   end

Used for abstraction & use with cloud helper

[Source]

     # File app/models/peer_group.rb, line 101
101:   def use_count
102:     return self.memberships_count
103:   end

Protected Instance methods

Creates a home-page for this PeerGroup.

[Source]

     # File app/models/peer_group.rb, line 163
163:   def create_home_page
164:     # see HomePageModule
165:     self.create_home_page_for(Tag.peer_group, :creator => self.admin,
166:         :user_group => GlobalConfig.public_user_group,
167:         :title => t('m.peer_group.home_title', :name => self.name),
168:         :body => '<p>' + t('m.peer_group.home_body', :name => self.name) +
169:             '</p>',
170:         :kind => Const::Logi::KINDS[:peer_group])
171:     return true
172:   end

Destroys the home page of the peer_group.

[Source]

     # File app/models/peer_group.rb, line 196
196:   def destroy_home_pages
197:     self.destroy_home_pages_for(Tag.peer_group)
198:     # see the HomePageModule
199:     return true
200:   end

Destroys all memberships.

[Source]

     # File app/models/peer_group.rb, line 187
187:   def destroy_memberships
188:     self.memberships.each do |membership|
189:       membership.destroy
190:     end
191:     return true
192:   end

Also sets the default_peer_group back to the default peer_group if it is destroyed.

[Source]

     # File app/models/peer_group.rb, line 177
177:   def reset_prefs_profiles
178:     self.prefs_profiles.each do |prefs_profile|
179:       prefs_profile.default_peer_group = PeerGroup.public
180:       prefs_profile.save
181:     end
182:     return true
183:   end

[Validate]