app/models/user.rb
# checks if the user can perform the given role for the given mission
# mission defaults to user's current mission
checks if the user can perform the given role for the given mission
mission defaults to user's current mission
checks if the user can perform the given role for the given mission mission defaults to user ' s current mission
def role?(base_role, mission)
    return true if admin?
    return false if mission.nil?
    mission_role = role(mission)
    if mission_role.nil?
      false
    else
      ROLES.index(base_role.to_s) <= ROLES.index(mission_role)
    end
  end
def role? ( base_role , mission ) return true if admin? return false if mission . nil? mission_role = role ( mission ) if mission_role . nil? false else ROLES . index ( base_role . to_s ) <= ROLES . index ( mission_role ) end end
checks if the user can perform the given role for the given mission
mission defaults to user's current mission
checks if the user can perform the given role for the given mission mission defaults to user ' s current mission
# admins can do anything # if no mission then the answer is trivially false # get the user's role for the specified mission # if the role is nil, we can return false # otherwise we compare the role indices
base_role
<not_specific>
mission
<not_specific>