Class: Group

Inherits:
ApplicationRecord show all
Includes:
FindEachWithOrder, MarkAsDeletedWithName
Defined in:
app/models/group.rb

Overview

Groups organize the User. A Member gets the roles from the Group

Direct Known Subclasses

Ordergroup, Workgroup

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#user_tokensObject

Returns the value of attribute user_tokens.



13
14
15
# File 'app/models/group.rb', line 13

def user_tokens
  @user_tokens
end

Instance Method Details

#deleted?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/group.rb', line 31

def deleted?
  deleted_at.present?
end

#mark_as_deletedObject



35
36
37
38
39
40
41
42
# File 'app/models/group.rb', line 35

def mark_as_deleted
  # TODO: Checks for participating in not closed orders
  transaction do
    memberships.destroy_all
    # @todo what should happen to the users?
    super
  end
end

#member?(user) ⇒ Boolean

Returns true if the given user if is an member of this group.

Returns:

  • (Boolean)


18
19
20
# File 'app/models/group.rb', line 18

def member?(user)
  memberships.find_by_user_id(user.id)
end

#non_membersObject

Returns all NONmembers and a checks for possible multiple Ordergroup-Memberships



23
24
25
# File 'app/models/group.rb', line 23

def non_members
  User.natural_order.reject { |u| users.include?(u) }
end