Sha256: 95420a2264bad4dc3cb20470789215f8cbfba0eed562d90f0ff32c13e749206a

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ProductCommand
      module CopyCommand
        class DeleteExistingTargetBackendUsagesTask
          attr_reader :context

          def initialize(context)
            @context = context
          end

          # entrypoint
          def call
            conflicting_target_backend_usage_list.each(&:delete)
          end

          private

          # List of target backend usage items that match source backend usage paths
          def conflicting_target_backend_usage_list
            # Compute array intersection
            target_backend_usage_list.select do |target_usage|
              source_backend_usage_list.find do |source_usage|
                target_usage.path == source_usage.path
              end
            end
          end

          def source_backend_usage_list
            @source_backend_usage_list ||= source.backend_usage_list
          end

          def target_backend_usage_list
            @target_backend_usage_list ||= target.backend_usage_list
          end

          def target
            context[:target]
          end

          def source
            context[:source]
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb