diff options
Diffstat (limited to 'lib/declarative_policy.rb')
-rw-r--r-- | lib/declarative_policy.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb index d99a209dc87..9e9df88373a 100644 --- a/lib/declarative_policy.rb +++ b/lib/declarative_policy.rb @@ -74,7 +74,14 @@ module DeclarativePolicy next unless klass.name begin - policy_class = "#{klass.name}Policy".constantize + klass_name = + if subject_class.respond_to?(:declarative_policy_class) + subject_class.declarative_policy_class + else + "#{klass.name}Policy" + end + + policy_class = klass_name.constantize # NOTE: the < operator here tests whether policy_class # inherits from Base. We can't use #is_a? because that |