Sha256: 8f7516463b381a09a3fe41c65dbae2f15bc36323143f1ee436283d9db6b01fc0

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'effective_resources'
require 'effective_datatables'
require 'effective_mentorships/engine'
require 'effective_mentorships/version'

module EffectiveMentorships

  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

  include EffectiveGem

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

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

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

  def self.MentorshipCycle
    Effective::MentorshipCycle
  end

  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

  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

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_mentorships-0.2.4 lib/effective_mentorships.rb
effective_mentorships-0.2.3 lib/effective_mentorships.rb
effective_mentorships-0.2.2 lib/effective_mentorships.rb
effective_mentorships-0.2.1 lib/effective_mentorships.rb
effective_mentorships-0.2.0 lib/effective_mentorships.rb
effective_mentorships-0.1.0 lib/effective_mentorships.rb
effective_mentorships-0.0.1 lib/effective_mentorships.rb