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
Iain Barnett authored and rkh committed Aug 21, 2011
1 parent 659a450 commit df866ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.rdoc
Expand Up @@ -140,7 +140,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
Expand Down

0 comments on commit df866ad

Please sign in to comment.