Last active
August 29, 2015 14:04
-
-
Save blackxored/7460c13f1a211e1c9164 to your computer and use it in GitHub Desktop.
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
module PunditExtensions | |
def authorize(record, query=nil, account_or_job=nil) | |
preload_permissions(record) | |
deal_with_account_or_job(record, account_or_job) if account_or_job | |
super | |
end | |
def preload_permissions(record) | |
@preloaded ||= {} | |
@preloaded[:permissions] ||= {} | |
@preloaded[:permissions].merge!(policy(record).to_permissions_hash) | |
end | |
def deal_with_account_or_job(record, account_or_job) | |
# ... | |
end | |
end | |
Pundit.send(:prepend, PunditExtensions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment