Class: Group
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Group
- 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
Instance Attribute Summary collapse
-
#user_tokens ⇒ Object
Returns the value of attribute user_tokens.
Instance Method Summary collapse
- #deleted? ⇒ Boolean
- #mark_as_deleted ⇒ Object
-
#member?(user) ⇒ Boolean
Returns true if the given user if is an member of this group.
-
#non_members ⇒ Object
Returns all NONmembers and a checks for possible multiple Ordergroup-Memberships.
Instance Attribute Details
#user_tokens ⇒ Object
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
31 32 33 |
# File 'app/models/group.rb', line 31 def deleted? deleted_at.present? end |
#mark_as_deleted ⇒ Object
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.
18 19 20 |
# File 'app/models/group.rb', line 18 def member?(user) memberships.find_by_user_id(user.id) end |
#non_members ⇒ Object
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 |