supporting deeply nested aliases - closes #98
This commit is contained in:
@@ -212,6 +212,15 @@ module CanCan
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Accepts a hash of aliased actions and returns an array of actions which match.
|
||||
# This should be called before "matches?" and other checking methods since they
|
||||
# rely on the actions to be expanded.
|
||||
def expand_actions(actions)
|
||||
actions.map do |action|
|
||||
aliased_actions[action] ? [action, *expand_actions(aliased_actions[action])] : action
|
||||
end.flatten
|
||||
end
|
||||
|
||||
def can_definitions
|
||||
@can_definitions ||= []
|
||||
@@ -219,7 +228,7 @@ module CanCan
|
||||
|
||||
def matching_can_definition(action, subject)
|
||||
can_definitions.reverse.detect do |can_definition|
|
||||
can_definition.expand_actions(aliased_actions)
|
||||
can_definition.expanded_actions = expand_actions(can_definition.actions)
|
||||
can_definition.matches? action, subject
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user