lib/ig_markets/cli/main.rb
# Takes a Thor options hash and filters out its keys in the specified whitelist. Thor has an unusual behavior
# when an option is specified without a value: its value is set to the option's name. This method resets any
# such occurrences to `nil`.
#
# @param [Thor::CoreExt::HashWithIndifferentAccess] options The Thor options.
# @param [Array<Symbol>] whitelist The list of options allowed in the returned `Hash`.
#
# @return [Hash]
Takes a Thor options hash and filters out its keys in the specified whitelist. Thor has an unusual behavior
when an option is specified without a value: its value is set to the option's name. This method resets any
such occurrences to `nil`.
Takes a Thor options hash and filters out its keys in the specified whitelist . Thor has an unusual behavior when an option is specified without a value : its value is set to the option ' s name . This method resets any such occurrences to ` nil ` .
def filter_options(options, whitelist)
          options.each_with_object({}) do |(key, value), new_hash|
            next unless whitelist.include? key.to_sym
            new_hash[key.to_sym] = value == key ? nil : value
          end
        end
def filter_options ( options , whitelist ) options . each_with_object ( { } ) do | ( key , value ) , new_hash | next unless whitelist . include? key . to_sym new_hash [ key . to_sym ] = value == key ? nil : value end end
Takes a Thor options hash and filters out its keys in the specified whitelist.
Takes a Thor options hash and filters out its keys in the specified whitelist .
None
Hash
options
whitelist
whitelist The list of options allowed in the returned `Hash`.
whitelist The list of options allowed in the returned ` Hash ` .