lib/authority/user_abilities.rb in authority-2.3.0 vs lib/authority/user_abilities.rb in authority-2.3.1
- old
+ new
@@ -18,11 +18,24 @@
end
end
RUBY
end
- def can?(action)
- ApplicationAuthorizer.send("can_#{action}?", self)
+ def can?(action, options = {})
+ begin
+ ApplicationAuthorizer.send("authorizes_to_#{action}?", self, options)
+ rescue NoMethodError => original_exception
+ begin
+ # For backwards compatibility
+ response = ApplicationAuthorizer.send("can_#{action}?", self, options)
+ Authority.logger.warn(
+ "DEPRECATION WARNING: Please rename `ApplicationAuthorizer.can_#{action}?` to `authorizes_to_#{action}?`"
+ )
+ response
+ rescue NoMethodError => new_exception
+ raise original_exception
+ end
+ end
end
end
end