summaryrefslogtreecommitdiff
path: root/lib/bulk_imports/pipeline/context.rb
blob: d753f888671e3890be6727d25cdc5d25630219cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

module BulkImports
  module Pipeline
    class Context
      attr_accessor :extra

      attr_reader :tracker

      def initialize(tracker, extra = {})
        @tracker = tracker
        @extra = extra
      end

      def entity
        @entity ||= tracker.entity
      end

      def portable
        @portable ||= entity.group || entity.project
      end

      def import_export_config
        @import_export_config ||= ::BulkImports::FileTransfer.config_for(portable)
      end

      def group
        @group ||= entity.group
      end

      def bulk_import
        @bulk_import ||= entity.bulk_import
      end

      def current_user
        @current_user ||= bulk_import.user
      end

      def configuration
        @configuration ||= bulk_import.configuration
      end
    end
  end
end