Class: Effective::ApplicantEndorsement

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/applicant_endorsement.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.endorser_collection(applicant) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/models/effective/applicant_endorsement.rb', line 60

def self.endorser_collection(applicant)
  raise('expected an effective memberships applicant') unless applicant.class.try(:effective_memberships_applicant?)

  collection_method = EffectiveMemberships.applicant_endorsements_endorser_collection()

  if collection_method.blank?
    return (applicant.user.class.members)
  end

  collection = instance_exec(applicant, &collection_method)

  unless collection.kind_of?(ActiveRecord::Relation)
    raise("expected EffectiveMemberships.applicant_endorsements_endorsers_collection to return an ActiveRecord::Relation.")
  end

  collection
end

Instance Method Details

#complete!Object



93
94
95
96
# File 'app/models/effective/applicant_endorsement.rb', line 93

def complete!
  completed!
  applicant.save!
end

#emailObject



82
83
84
# File 'app/models/effective/applicant_endorsement.rb', line 82

def email
  endorser&.email || endorser_email
end

#notify!Object



86
87
88
89
90
91
# File 'app/models/effective/applicant_endorsement.rb', line 86

def notify!
  raise('expected endorsement email') unless email.present?

  EffectiveMemberships.send_email(:applicant_endorsement_notification, self)
  update!(last_notified_at: Time.zone.now)
end

#to_sObject



78
79
80
# File 'app/models/effective/applicant_endorsement.rb', line 78

def to_s
  'endorsement'
end