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.
Instance Method Details
#build_mentorship_group(mentorship_cycle:) ⇒ Object
Find or build
37 38 39 40 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 37 def build_mentorship_group(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?) mentorship_group(mentorship_cycle: mentorship_cycle) || mentorship_groups.build(mentorship_cycle: mentorship_cycle) end |
#build_mentorship_registration(mentorship_cycle:) ⇒ Object
Find or build
49 50 51 52 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 49 def build_mentorship_registration(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?) mentorship_registration(mentorship_cycle: mentorship_cycle) || mentorship_registrations.build(mentorship_cycle: mentorship_cycle) end |
#mentorship_group(mentorship_cycle:) ⇒ Object
Find
31 32 33 34 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 31 def mentorship_group(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?) mentorship_groups.find { |mentorship_group| mentorship_group.mentorship_cycle_id == mentorship_cycle.id } end |
#mentorship_registration(mentorship_cycle:) ⇒ Object
Find
43 44 45 46 |
# File 'app/models/concerns/effective_mentorships_user.rb', line 43 def mentorship_registration(mentorship_cycle:) raise('expected an MentorshipCycle') unless mentorship_cycle.class.respond_to?(:effective_mentorships_mentorship_cycle?) mentorship_registrations.find { |mentorship_registration| mentorship_registration.mentorship_cycle_id == mentorship_cycle.id } end |