debian-mirror-gitlab/app/controllers/concerns/find_snippet.rb

29 lines
507 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module FindSnippet
extend ActiveSupport::Concern
include Gitlab::Utils::StrongMemoize
private
# rubocop:disable CodeReuse/ActiveRecord
def snippet
strong_memoize(:snippet) do
2021-10-27 15:23:28 +05:30
snippet_klass.inc_relations_for_view.find_by(snippet_find_params)
2020-06-23 00:09:42 +05:30
end
end
# rubocop:enable CodeReuse/ActiveRecord
def snippet_klass
raise NotImplementedError
end
def snippet_id
params[:id]
end
2021-10-27 15:23:28 +05:30
def snippet_find_params
{ id: snippet_id }
end
2020-06-23 00:09:42 +05:30
end