Module: EffectiveMentorshipsUser
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_mentorships_user.rb
Overview
EffectiveMentorshipsUser
Mark your user model with effective_mentorship_user to get a few helpers And user specific point required scores
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#build_mentorship_group(mentorship_cycle:) ⇒ Object
Find or build.
-
#build_mentorship_registration(mentorship_cycle:) ⇒ Object
Find or build.
-
#mentorship_group(mentorship_cycle:) ⇒ Object
Find.
-
#mentorship_registration(mentorship_cycle:) ⇒ Object
Find.
- #mentorship_registrations_without_groups ⇒ Object
-
#registrable_mentorship_cycles ⇒ Object
Used for the dashboard datatables.
Instance Method Details
#build_mentorship_group(mentorship_cycle:) ⇒ Object
Find or build
92 93 94 95 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 92 def build_mentorship_group(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_cycle?) mentorship_group(mentorship_cycle: mentorship_cycle) || mentorship_groups.build(mentorship_cycle: mentorship_cycle) end |
#build_mentorship_registration(mentorship_cycle:) ⇒ Object
Find or build
104 105 106 107 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 104 def build_mentorship_registration(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_cycle?) mentorship_registration(mentorship_cycle: mentorship_cycle) || mentorship_registrations.build(mentorship_cycle: mentorship_cycle) end |
#mentorship_group(mentorship_cycle:) ⇒ Object
Find
86 87 88 89 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 86 def mentorship_group(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_cycle?) mentorship_groups.find { |mentorship_group| mentorship_group.mentorship_cycle_id == mentorship_cycle.id } end |
#mentorship_registration(mentorship_cycle:) ⇒ Object
Find
98 99 100 101 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 98 def mentorship_registration(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_cycle?) mentorship_registrations.find { |mentorship_registration| mentorship_registration.mentorship_cycle_id == mentorship_cycle.id } end |
#mentorship_registrations_without_groups ⇒ Object
81 82 83 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 81 def mentorship_registrations_without_groups mentorship_registrations.where.not(mentorship_cycle_id: mentorship_group_users.select(:mentorship_cycle_id)) end |
#registrable_mentorship_cycles ⇒ Object
Used for the dashboard datatables. Which cycles can we register for?
75 76 77 78 79 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 75 def registrable_mentorship_cycles Effective::MentorshipCycle.registrable .where.not(id: mentorship_group_users.select(:mentorship_cycle_id)) .where.not(id: mentorship_registrations.select(:mentorship_cycle_id)) end |