Sha256: f37b797b53bdaa9f74ab8d8c479bdc6a8392a22467a8bd96a65e5b2abea4cf08

Contents?: true

Size: 914 Bytes

Versions: 5

Compression:

Stored size: 914 Bytes

Contents

module Departure
  # 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

5 entries across 5 versions & 1 rubygems

Version Path
departure-4.0.0 lib/departure/user_options.rb
departure-2.0.1 lib/departure/user_options.rb
departure-3.0.1 lib/departure/user_options.rb
departure-3.0.0 lib/departure/user_options.rb
departure-2.0.0 lib/departure/user_options.rb