mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
added example for condition with array argument
This commit is contained in:
parent
205fe10ff3
commit
8b5fcf47a7
1 changed files with 18 additions and 0 deletions
18
README.rdoc
18
README.rdoc
|
@ -141,7 +141,25 @@ You can easily define your own conditions:
|
|||
get '/win_a_car' do
|
||||
"Sorry, you lost."
|
||||
end
|
||||
|
||||
For a condition that takes multiple values use a splat:
|
||||
|
||||
set(:auth) do |*roles| # <- notice the splat here
|
||||
condition do
|
||||
unless logged_in? && roles.any? {|role| current_user.in_role? role }
|
||||
redirect "/login/", 303
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
get "/my/account/", :auth => [:user, :admin] do
|
||||
"Your Account Details"
|
||||
end
|
||||
|
||||
get "/only/admin/", :auth => :admin do
|
||||
"Only admins are allowed here!"
|
||||
end
|
||||
|
||||
=== Return Values
|
||||
|
||||
The return value of a route block determines at least the response body passed
|
||||
|
|
Loading…
Reference in a new issue