Skip to content

Instantly share code, notes, and snippets.

@bencates
Created March 5, 2016 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bencates/3bc82dd97fb576cf6626 to your computer and use it in GitHub Desktop.
Save bencates/3bc82dd97fb576cf6626 to your computer and use it in GitHub Desktop.
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