summaryrefslogtreecommitdiff
path: root/app/policies/todo_policy.rb
blob: d01a046c34398b11fbdb8b4ef5b9b985806551e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
# frozen_string_literal: true

class TodoPolicy < BasePolicy
  desc 'User can only read own todos'
  condition(:own_todo) do
    @user && @subject.user_id == @user.id
  end

  rule { own_todo }.enable :read_todo
  rule { own_todo }.enable :update_todo
end