Class: Effective::ApplicantEndorsement

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#email_form_skipObject

Returns the value of attribute email_form_skip.



7
8
9
# File 'app/models/effective/applicant_endorsement.rb', line 7

def email_form_skip
  @email_form_skip
end

Class Method Details

.endorser_collection(applicant) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/models/effective/applicant_endorsement.rb', line 66

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



99
100
101
102
# File 'app/models/effective/applicant_endorsement.rb', line 99

def complete!
  completed!
  applicant.save!
end

#emailObject



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

def email
  endorser&.email || endorser_email
end

#notify!Object



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

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



84
85
86
# File 'app/models/effective/applicant_endorsement.rb', line 84

def to_s
  'endorsement'
end