Created
October 29, 2014 14:02
-
-
Save ckozus/5ec61c5359b8421e5317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.get_superiors_of(user) | |
superiors = Array.new | |
return superiors if user.departament.nil? | |
case user.is_chief | |
when true | |
unless user.departament.parent.nil? | |
superiors = user.departament.parent.users.chiefs.to_a | |
end | |
when false | |
if user.departament.users.chiefs.to_a.count > 0 | |
superiors = user.departament.users.chiefs.to_a | |
else | |
unless user.departament.parent.nil? | |
superiors = user.departament.parent.users.chiefs.to_a | |
end | |
end | |
end | |
superiors | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment