Skip to content

Commit

Permalink
Added example for condition with array argument
Browse files Browse the repository at this point in the history
  • Loading branch information
michelc committed Sep 1, 2011
1 parent 9ac30d5 commit 9ca62c3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.fr.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ Vous pouvez facilement définir vos propres conditions :
"Désolé, vous avez perdu."
end

Utilisez un splat (caractère joker) dans le cas d'une condition qui prend
plusieurs valeurs :

set(:auth) do |*roles| # <- ici on utilise un splat
condition do
unless logged_in? && roles.any? {|role| current_user.in_role? role }
redirect "/login/", 303
end
end
end

get "/mon/compte/", :auth => [:user, :admin] do
"Informations sur votre compte"
end

get "/reserve/aux/admins/", :auth => :admin do
"Seuls les administrateurs sont acceptés ici !"
end

=== Valeurs de retour

La valeur renvoyée par le bloc correspondant à une route constitue le corps de
Expand Down

0 comments on commit 9ca62c3

Please sign in to comment.