1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class LicenseStatus ACTIVE=Active.new EXPIRED=Expired.new CONFIDENTIAL=Confidential.new UNKNOWN=Object.new ALL=[ACTIVE, EXPIRED, CONFIDENTIAL] def self.find_match(status = "") ALL.find { |x| x.matches?("#{status}".downcase) } || ACTIVE end def self.status_for(license) ALL.find { |x| x.best_represents?(license) } || UNKNOWN end end