nathanl / authority

*CURRENTLY UNMAINTAINED*. Authority helps you authorize actions in your Rails app. It's ORM-neutral and has very little fancy syntax; just group your models under one or more Authorizer classes and write plain Ruby methods on them.
MIT License
1.21k stars 67 forks source link

Allow authorize_actions_for to pass options #75

Closed ghost closed 10 years ago

ghost commented 10 years ago

This change simply splats the result of the method called to get the resource to authorize in a controller (as a result of using the .authorize_actions_for class method).

This will have no effect on existing calls, since the .authorize_actions_for previously supported only a resource method that returns a single value.

This change will allow someone to return an array in their resource method, including both the resource to authorize and options. This can be very helpful for authorizing create actions.

For example:

class WibblesController before_filter :load_foo authorize_actions_for :foo_wibbles, only: :create

...

private

def foo_wibbles [Wibble, { foo_id: @foo }] end end

ghost commented 10 years ago

Sorry for the build break; I didn't think to consider the ruby 1.8.7 syntax.

nathanl commented 10 years ago

@orchardadam Cool, thanks for the patch!