chaps-io/access-granted

Object and Subobject

sadjehwty opened this issue · 1 comments

How can I define rule for a subobject extends object rule.
es.

can :delete, Object do |obj, user|
  post.author_id == user.id
end
can :delete, Subobject do |sub, user|
  can? :delete, sub.parent && sub.id>3
end

Hi! If I understood you correctly, then: there is no inheritance between can blocks and Access Granted has no special handling for inheritance of Ruby classes.

You can DRY it up by extracting common logic into methods and use that in blocks