2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-25 19:23:47 +00:00
|
|
|
|
2015-12-17 01:03:51 +00:00
|
|
|
class Perm
|
2015-12-17 01:10:52 +00:00
|
|
|
# e.g. Perm::ISSIONS
|
2017-11-25 19:23:47 +00:00
|
|
|
ISSIONS = %i(commons public private).freeze
|
2015-12-17 01:10:52 +00:00
|
|
|
|
2015-12-17 01:03:51 +00:00
|
|
|
class << self
|
|
|
|
def short(permission)
|
|
|
|
case permission
|
|
|
|
when :commons
|
2016-07-26 00:14:23 +00:00
|
|
|
'co'
|
2015-12-17 01:03:51 +00:00
|
|
|
when :public
|
2016-07-26 00:14:23 +00:00
|
|
|
'pu'
|
2015-12-17 01:03:51 +00:00
|
|
|
when :private
|
2016-07-26 00:14:23 +00:00
|
|
|
'pr'
|
2015-12-17 01:03:51 +00:00
|
|
|
else
|
2016-07-26 00:14:23 +00:00
|
|
|
raise 'Invalid permission'
|
2015-12-17 01:03:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def long(perm)
|
|
|
|
case perm
|
2016-07-26 00:14:23 +00:00
|
|
|
when 'co'
|
2015-12-17 01:03:51 +00:00
|
|
|
:commons
|
2016-07-26 00:14:23 +00:00
|
|
|
when 'pu'
|
2015-12-17 01:03:51 +00:00
|
|
|
:public
|
2016-07-26 00:14:23 +00:00
|
|
|
when 'pr'
|
2015-12-17 01:03:51 +00:00
|
|
|
:private
|
|
|
|
else
|
2016-07-26 00:14:23 +00:00
|
|
|
raise 'Invalid short permission'
|
2015-12-17 01:03:51 +00:00
|
|
|
end
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2015-12-17 01:03:51 +00:00
|
|
|
def valid?(permission)
|
|
|
|
ISSIONS.include? permission
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|