Class: Usergroup

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Authorization
Defined in:
app/models/usergroup.rb

Instance Method Summary collapse

Methods included from Authorization

#enforce_create_permissions, #enforce_destroy_permissions, #enforce_edit_permissions, #enforce_permissions, included, #permission_failed?

Instance Method Details

#all_usergroups(group_list = [self], user_list = []) ⇒ Object

This methods retrieves all usergroups in a usergroup Returns: Array of unique usergroups


33
34
35
36
# File 'app/models/usergroup.rb', line 33

def all_usergroups(group_list=[self], user_list=[])
  retrieve_users_and_groups group_list, user_list
  group_list.sort.uniq
end

#all_users(group_list = [self], user_list = []) ⇒ Object

This methods retrieves all users in a usergroup Returns: Array of users


26
27
28
29
# File 'app/models/usergroup.rb', line 26

def all_users(group_list=[self], user_list=[])
  retrieve_users_and_groups group_list, user_list
  user_list.sort.uniq
end

#as_json(options = {}) ⇒ Object


38
39
40
# File 'app/models/usergroup.rb', line 38

def as_json(options={})
  super({:only => [:name, :id]})
end

#recipientsObject

This methods retrieves all user addresses in a usergroup Returns: Array of strings representing the user's email addresses


20
21
22
# File 'app/models/usergroup.rb', line 20

def recipients
  all_users.map(&:mail).flatten.sort.uniq
end