Sha256: f7905ebdc31cd759e41a1ee832191034b028addbce1f5c3040e2d35b2225ec18

Contents?: true

Size: 920 Bytes

Versions: 2

Compression:

Stored size: 920 Bytes

Contents

module PerconaMigrator
  # Encapsulates the pt-online-schema-change options defined by the user
  class UserOptions
    delegate :each, :merge, to: :to_set

    # Constructor
    #
    # @param arguments [String]
    def initialize(arguments = ENV['PERCONA_ARGS'])
      @arguments = arguments
    end

    private

    attr_reader :arguments

    # Returns the arguments the user defined but without duplicates
    #
    # @return [Set]
    def to_set
      Set.new(user_options)
    end

    # Returns Option instances from the arguments the user specified, if any
    #
    # @return [Array]
    def user_options
      if arguments
        build_options
      else
        []
      end
    end

    # Builds Option instances from the user arguments
    #
    # @return [Array<Option>]
    def build_options
      arguments.split(' ').map do |argument|
        Option.from_string(argument)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percona_migrator-3.0.0 lib/percona_migrator/user_options.rb
percona_migrator-1.1.0 lib/percona_migrator/user_options.rb