metamaps--metamaps/app/services/perm.rb

39 lines
622 B
Ruby
Raw Permalink Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
2017-11-06 16:15:18 +00:00
class Perm
# e.g. Perm::ISSIONS
2017-11-06 16:15:18 +00:00
ISSIONS = %i(commons public private).freeze
class << self
def short(permission)
case permission
when :commons
'co'
when :public
'pu'
when :private
'pr'
else
raise 'Invalid permission'
end
end
def long(perm)
case perm
when 'co'
:commons
when 'pu'
:public
when 'pr'
:private
else
raise 'Invalid short permission'
end
end
def valid?(permission)
ISSIONS.include? permission
end
end
end