Sha256: b1a56b7db5e91f8e1f71f199a3c1e03ce9250e3bc0428675d2daf76639a1d2f7

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 Bytes

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      module CopyCommand
        class DestroyMappingRulesTask
          attr_reader :context

          def initialize(context)
            @context = context
          end

          def call
            return unless delete_mapping_rules

            logger.info 'destroying all mapping rules'
            target.mapping_rules.each(&:delete)
          end

          private

          def delete_mapping_rules
            context.fetch(:delete_mapping_rules, false)
          end

          def target
            context.fetch(:target)
          end

          def logger
            context[:logger] ||= Logger.new($stdout).tap do |logger|
              logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}\n" }
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb