-
-
Save patcoll/4c8cb3cf33b520ff424f43eb82a2ead8 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 Luma | |
class Policy | |
def initialize(user, model) | |
@user = user | |
@model = model | |
end | |
%w(create read see update change destroy manage search).freeze.each do |attr| | |
define_method("#{attr}?".to_sym) do | |
@user&.send(:can?, attr.to_sym, @model) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment