Files
nairobi/app/models/ability.rb
kikito 82af488ce3 Splits ability.rb and specs into several smaller files
I'm doing this in preparation for the "Manager" ability, which will
require even more refactors of the abilities (for example,
manager can not modify their own account)
2015-09-28 13:51:42 +02:00

23 lines
544 B
Ruby

class Ability
include CanCan::Ability
def initialize(user)
# If someone can hide something, he can also hide it
# from the moderation screen
alias_action :hide_in_moderation_screen, to: :hide
if user # logged-in users
if user.administrator?
self.merge Abilities::Administrator.new(user)
elsif user.moderator?
self.merge Abilities::Moderator.new(user)
else
self.merge Abilities::Common.new(user)
end
else
self.merge Abilities::Everyone.new(user)
end
end
end