lib/authorization.rb
# Returns the role symbols of the given user.
Returns the role symbols of the given user.
Returns the role symbols of the given user .
def roles_for (user)
      raise AuthorizationUsageError, "User object doesn't respond to roles" \
        if !user.respond_to?(:role_symbols) and !user.respond_to?(:roles)
      RAILS_DEFAULT_LOGGER.info("The use of user.roles is deprecated.  Please add a method " +
          "role_symbols to your User model.") if defined?(RAILS_DEFAULT_LOGGER) and !user.respond_to?(:role_symbols)
      roles = user.respond_to?(:role_symbols) ? user.role_symbols : user.roles
      raise AuthorizationUsageError, "User.#{user.respond_to?(:role_symbols) ? 'role_symbols' : 'roles'} " +
        "doesn't return an Array of Symbols (#{roles.inspect})" \
            if !roles.is_a?(Array) or (!roles.empty? and !roles[0].is_a?(Symbol))
      (roles.empty? ? [:guest] : roles)
    end
def roles_for ( user ) raise AuthorizationUsageError , "User object doesn't respond to roles" if ! user . respond_to? ( :role_symbols ) and ! user . respond_to? ( :roles ) RAILS_DEFAULT_LOGGER . info ( "The use of user.roles is deprecated.  Please add a method " + "role_symbols to your User model." ) if defined? ( RAILS_DEFAULT_LOGGER ) and ! user . respond_to? ( :role_symbols ) roles = user . respond_to? ( :role_symbols ) ? user . role_symbols : user . roles raise AuthorizationUsageError , "User.#{user.respond_to?(:role_symbols) ? 'role_symbols' : 'roles'} " + "doesn't return an Array of Symbols (#{roles.inspect})" if ! roles . is_a? ( Array ) or ( ! roles . empty? and ! roles [ 0 ] . is_a? ( Symbol ) ) ( roles . empty? ? [ :guest ] : roles ) end
Returns the role symbols of the given user.
Returns the role symbols of the given user .
user
<not_specific>