Created
January 27, 2016 21:24
-
-
Save cheeyeo/c7082801fe0b62ae6485 to your computer and use it in GitHub Desktop.
Refactory Ruby case using Hashes
This file contains hidden or 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
STUDENT_LEVELS = Hash.new(Student::Unregistered).merge( | |
freshman: Student::Underclassman, | |
sophomore: Student::Underclassman, | |
junior: Student::Upperclassman, | |
senior: Student::Upperclassman, | |
graduate: Student::Graduate | |
) | |
klass = STUDENT_LEVELS[params[:student_level]] | |
student = klass.new(name, birthdate, address, phone) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment