Class: BulkImports::SourceUrlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bulk_imports/source_url_builder.rb

Constant Summary collapse

ALLOWED_RELATIONS =
%w[
  issues
  merge_requests
  epics
  milestones
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, entry) ⇒ SourceUrlBuilder

Returns a new instance of SourceUrlBuilder.

Parameters:



16
17
18
19
20
# File 'lib/bulk_imports/source_url_builder.rb', line 16

def initialize(context, entry)
  @context = context
  @entity = context.entity
  @entry = entry
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/bulk_imports/source_url_builder.rb', line 12

def context
  @context
end

#entityObject (readonly)

Returns the value of attribute entity.



12
13
14
# File 'lib/bulk_imports/source_url_builder.rb', line 12

def entity
  @entity
end

#entryObject (readonly)

Returns the value of attribute entry.



12
13
14
# File 'lib/bulk_imports/source_url_builder.rb', line 12

def entry
  @entry
end

Instance Method Details

#urlObject

Builds a source URL for the given entry if iid is present



23
24
25
26
27
28
29
# File 'lib/bulk_imports/source_url_builder.rb', line 23

def url
  return unless entry.is_a?(ApplicationRecord)
  return unless iid
  return unless ALLOWED_RELATIONS.include?(relation)

  File.join(source_instance_url, group_prefix, source_full_path, '-', relation, iid.to_s)
end