Skip to content

Instantly share code, notes, and snippets.

@farnoy
Last active December 25, 2015 08:59
Show Gist options
  • Save farnoy/6950927 to your computer and use it in GitHub Desktop.
Save farnoy/6950927 to your computer and use it in GitHub Desktop.
Draft rails adapter for access granted
class Roles::Moderator
applies_for -> user { user.moderator? }
definitions do
can :edit, Comment
can :destroy, Thread, locked: false
can :unlock, Thread, If(:locked_by_him)
end
def locked_by_him
@subject.locked_by == @user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment