Skip to content

Instantly share code, notes, and snippets.

@dchandekstark
Created May 5, 2015 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchandekstark/cfbef5b7081a221a5468 to your computer and use it in GitHub Desktop.
Save dchandekstark/cfbef5b7081a221a5468 to your computer and use it in GitHub Desktop.
Ability Class
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