2020-10-23 11:08:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module BulkImports
|
|
|
|
module Pipeline
|
|
|
|
class Context
|
|
|
|
include Gitlab::Utils::LazyAttributes
|
|
|
|
|
|
|
|
Attribute = Struct.new(:name, :type)
|
|
|
|
|
|
|
|
PIPELINE_ATTRIBUTES = [
|
|
|
|
Attribute.new(:current_user, User),
|
2020-11-06 04:08:56 -05:00
|
|
|
Attribute.new(:entity, ::BulkImports::Entity),
|
2020-10-23 11:08:42 -04:00
|
|
|
Attribute.new(:configuration, ::BulkImports::Configuration)
|
|
|
|
].freeze
|
|
|
|
|
|
|
|
def initialize(args)
|
|
|
|
assign_attributes(args)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
PIPELINE_ATTRIBUTES.each do |attr|
|
|
|
|
lazy_attr_reader attr.name, type: attr.type
|
|
|
|
end
|
|
|
|
|
|
|
|
def assign_attributes(values)
|
|
|
|
values.slice(*PIPELINE_ATTRIBUTES.map(&:name)).each do |name, value|
|
|
|
|
instance_variable_set("@#{name}", value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|