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


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

def user_tokens
  @user_tokens
end

Instance Method Details

#deleted?Boolean

Returns:

  • (Boolean)

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

def deleted?
  deleted_at.present?
end

#mark_as_deletedObject


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

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)

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

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

#non_membersObject

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


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

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