Welcome to mirror list, hosted at ThFree Co, Russian Federation.

read_only_relation.rb « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2362208e5ddbfd675040bb3a1c1caa881fe487c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module Gitlab
  module Database
    # Module that can be injected into a ActiveRecord::Relation to make it
    # read-only.
    module ReadOnlyRelation
      [:delete, :delete_all, :update, :update_all].each do |method|
        define_method(method) do |*args|
          raise(
            ActiveRecord::ReadOnlyRecord,
            "This relation is marked as read-only"
          )
        end
      end
    end
  end
end