Created
December 26, 2016 06:02
-
-
Save anonymous/4225dc1ddfadec07fde41fee0a6e6a0f 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
# Adds common methods to statuses | |
module Status | |
def name(status) | |
NAMES[status] | |
end | |
def names | |
NAMES | |
end | |
def valid?(status) | |
@statuses ||= constants.map { |c| const_get(c) } | |
@statuses.include?(status) | |
end | |
end | |
# Completed activity statuses | |
module ActivityStatus | |
extend Status | |
COMPLETED = 0 | |
ATTEMPTED = 1 | |
# I need to get this from the Status module | |
NAMES = { | |
COMPLETED => 'Completed', | |
ATTEMPTED => 'Attempted' | |
}.freeze | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment