Skip to content

Instantly share code, notes, and snippets.

@hassox
Created November 20, 2008 01:05
Show Gist options
  • Save hassox/26869 to your computer and use it in GitHub Desktop.
Save hassox/26869 to your computer and use it in GitHub Desktop.
class Merb::Authorization
operator_classes User, Staff, Customer, Group, String, Hash
operator_aliases :can?, is?, :authorized_for?, :authorized_to?, :authorized_with?
end
## The aliases allow for
user.authorized?
user.can?
user.is?
user.authorized_for?
user.authorized_to?
user.authorized_with?
## Example
user.authorized?(:edit, "Admin", :target => @project)
user.can?(:edit, :target => @article)
user.is?(:publisher, "Admin")
user.authorized_for?(:draft, :target => Article)
user.authorized_to?(:update, :target => @post)
user.authorized_with?(:cool_permissions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment