Module: EffectiveCommitteesUser
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_committees_user.rb
Overview
EffectiveCommitteesUser
Mark your user model with effective_committees_user to get all the includes
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#build_committee_member(committee:) ⇒ Object
Find or build.
-
#committee_member(committee:) ⇒ Object
Instance Methods.
- #committees ⇒ Object
Instance Method Details
#build_committee_member(committee:) ⇒ Object
Find or build
40 41 42 |
# File 'app/models/concerns/effective_committees_user.rb', line 40 def build_committee_member(committee:) committee_member(committee: committee) || committee_members.build(committee: committee) end |
#committee_member(committee:) ⇒ Object
Instance Methods
35 36 37 |
# File 'app/models/concerns/effective_committees_user.rb', line 35 def committee_member(committee:) committee_members.find { |rep| rep.committee_id == committee.id } end |
#committees ⇒ Object
44 45 46 |
# File 'app/models/concerns/effective_committees_user.rb', line 44 def committees committee_members.select { |cm| cm.active? && !cm.marked_for_destruction? }.map { |cm| cm.committee } end |