elabs/pundit — pull request #48 by randoum (2013-08-11 11:53:43+00:00)
Title: Policies custom parameters

This suggestion allows to add parameters to policies and scopes, and allow custom scopes.

I let you guys have a look before I write the documentation (if ever you consider it useful).
It is backward compatible, and wont break existing code.
Spec file included

### Policy with parameters

Basically, you can create policy such as:
```
class UserPolicy
def update?(new_attribute)
# check on permission according to the new attribute
end
end
```

And call `authorize @user, the_new_param` in your `update` action.

### Custom scope

It is also possible to specify a custom scope:
```
class UserPolicy
class Scope
def resolve
# Default Scope
end

def users_list_in_a_specific_case
# Specific scope
end
end
end
```

Then you can call `policy_scope(User, :users_list_in_a_specific_case)`

### Custom scope with parameters

A custom scope can accept parameters:
```
class UserPolicy
class Scope
def resolve
# Default Scope
end

def users_list_in_a_specific_case(additional_data)
# Specific scope
end
end
end
```

Then you can call `policy_scope(User, :users_list_in_a_specific_case, the_important_data)`