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: 4571ad122ce4bf39d155a09427ec162093c2834b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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