# frozen_string_literal: true class ApplicationResource < Graphiti::Resource include Pundit before_save(only: :create) { |record| authorize(record, :create?) } before_save(only: :update) do |record| # This can get called for associations that don't make changes, so we also need to check for changes # https://github.com/graphiti-api/graphiti/issues/165 authorize(record, :update?) if record.changed? end before_destroy { |record| authorize(record, :destroy?) } def base_scope policy_scope(model) end private def current_user context.try(:current_user) end end