Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2016 06:02
Show Gist options
  • Save anonymous/4225dc1ddfadec07fde41fee0a6e6a0f to your computer and use it in GitHub Desktop.
Save anonymous/4225dc1ddfadec07fde41fee0a6e6a0f to your computer and use it in GitHub Desktop.
# 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