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



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

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



102
103
104
105
# File 'app/models/effective/applicant_endorsement.rb', line 102

def complete!
  completed!
  applicant.save!
end

#emailObject



91
92
93
# File 'app/models/effective/applicant_endorsement.rb', line 91

def email
  endorser&.email || endorser_email
end

#notify!Object



95
96
97
98
99
100
# File 'app/models/effective/applicant_endorsement.rb', line 95

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



83
84
85
86
87
88
89
# File 'app/models/effective/applicant_endorsement.rb', line 83

def to_s
  if (endorser.present? || name.present?)
    "#{model_name.human} from #{endorser || name}"
  else
    model_name.human
  end
end