Created
May 5, 2015 21:44
-
-
Save dchandekstark/cfbef5b7081a221a5468 to your computer and use it in GitHub Desktop.
Ability Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
class_attribute :permissions | |
attr_reader :user | |
def initialize(user) | |
@user = user | |
apply_permissions | |
end | |
private | |
def apply_permissions | |
if permissions.respond_to?(:call) | |
permissions.call(self) | |
else | |
instance_eval(permissions) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment