We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
27 lines
711 B
Ruby
27 lines
711 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
|
|
merge Abilities::Valuator.new(user) if user.valuator?
|
|
merge Abilities::Tracker.new(user) if user.tracker?
|
|
|
|
if user.administrator?
|
|
merge Abilities::Administrator.new(user)
|
|
elsif user.moderator?
|
|
merge Abilities::Moderator.new(user)
|
|
elsif user.manager?
|
|
merge Abilities::Manager.new(user)
|
|
else
|
|
merge Abilities::Common.new(user)
|
|
end
|
|
else
|
|
merge Abilities::Everyone.new(user)
|
|
end
|
|
end
|
|
end
|