Skip to content

Object Model Realignments on the Merge Train Product Category

The following discussion from !51433 (merged) should be addressed:

  • @fabiopitino started a discussion: (+2 comments)

    @shinya.maeda In one refactoring I'm working on (on the side) to solve exactly this product vs code mismatch I'm introducing MergeTrains namespace for models too. In there there will be:

    • move MergeTrain to MergeTrains::Car. A merge request on train does not represent the whole train but a single car.
    • introduce a (non-ActiveRecord) model class MergeTrains::Train that would represent the whole train. Currently we user MergeTrain class methods for that but this refactoring would make it more explicit.

    It's going to look something like this:

    class MergeTrains::Train
      attr_reader :project, :target_branch
    
      def initialize(project, target_branch)
        # ...
      end
    
      def refresh!
        # ...
      end
    
      def drop_merge_request(merge_request)
        # ...
      end
    
      def queue_id
        # ...
      end
    
      def first_car
        # ...
      end
    end

    The current MergeTrain class would be containing only methods related to the train car. With that we could rename a few things like MergeTrains::RefreshMergeRequestsService -> MergeTrains::RefreshMergeTrainService and MergeTrains::RefreshMergeRequestService -> MergeTrains::RefreshCarService.

Edited by Shinya Maeda