Created
March 5, 2016 02:20
-
-
Save bencates/3bc82dd97fb576cf6626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Applicant | |
def recent_rejection_reasons | |
rejection_reasons.where("rejection_reasons.created_at > '#{longest_days_ago}'") | |
end | |
end | |
class RejectionReason | |
def recently_rejected? | |
recency_cutoff = RejectionReason::REJECTION_REASON_CODES[reason_code][:days_blocked].days.ago | |
created_at > recency_cutoff | |
end | |
end | |
def longest_days_ago | |
RejectionReason::REJECTION_REASON_CODES | |
.max_by{ |k,v| v[:days_blocked] } | |
.first[:days_blocked] | |
.days.ago | |
end | |
elsif (rrs = applicant.recent_rejection_reasons).any?(&:recently_rejected?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment