Module: EffectiveMentorships

Includes:
EffectiveGem
Defined in:
lib/effective_mentorships.rb,
lib/effective_mentorships/engine.rb,
lib/effective_mentorships/version.rb,
lib/generators/effective_mentorships/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'0.2.4'

Class Method Summary collapse

Class Method Details

.config_keysObject



8
9
10
11
12
13
14
15
# File 'lib/effective_mentorships.rb', line 8

def self.config_keys
  [
    :mentorship_cycles_table_name, :mentorship_groups_table_name, :mentorship_registrations_table_name,
    :mentorship_group_class_name, :mentorship_registration_class_name,
    :layout,
    :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_froms, :mailer_admin, :mailer_subject,
  ]
end

.current_mentorship_cycle(date: nil) ⇒ Object



35
36
37
38
39
# File 'lib/effective_mentorships.rb', line 35

def self.current_mentorship_cycle(date: nil)
  date ||= Time.zone.now
  mentorship_cycles = Effective::MentorshipCycle.all.reorder(start_at: :asc).all.where('start_at <= ?', date)
  mentorship_cycles.to_a.last
end

.mailer_classObject



19
20
21
# File 'lib/effective_mentorships.rb', line 19

def self.mailer_class
  mailer&.constantize || Effective::MentorshipsMailer
end

.MentorshipCycleObject



31
32
33
# File 'lib/effective_mentorships.rb', line 31

def self.MentorshipCycle
  Effective::MentorshipCycle
end

.MentorshipGroupObject



23
24
25
# File 'lib/effective_mentorships.rb', line 23

def self.MentorshipGroup
  mentorship_group_class_name&.constantize || Effective::MentorshipGroup
end

.MentorshipRegistrationObject



27
28
29
# File 'lib/effective_mentorships.rb', line 27

def self.MentorshipRegistration
  mentorship_registration_class_name&.constantize || Effective::MentorshipRegistration
end

.previous_mentorship_cycle(date: nil) ⇒ Object



41
42
43
44
45
# File 'lib/effective_mentorships.rb', line 41

def self.previous_mentorship_cycle(date: nil)
  date ||= Time.zone.now
  mentorship_cycles = Effective::MentorshipCycle.all.reorder(start_at: :asc).all.where('start_at <= ?', date)
  mentorship_cycles.to_a.last(2).first
end