lib/rake/funnel/support/mapper.rb in rake-funnel-0.18.0 vs lib/rake/funnel/support/mapper.rb in rake-funnel-0.19.0

- old
+ new

@@ -14,32 +14,33 @@ raise "You cannot use the 'nil' mapper style. Available mappers are: #{available.inspect}" if style.nil? @style = create(style) end - def map(args = {}) - model = (args || {}).map { |switch, value| + def map(args = {}) # rubocop:disable Metrics/MethodLength + model = (args || {}).map do |switch, value| value = [value] unless value.is_a?(Array) values = value.map do |val| get_values(val) end Switch.new(switch, values) - }.flatten + end.flatten @style .generate_from(model) - .map { |args| args.map { |arg| camel_case_symbols(arg) } } + .map { |arguments| arguments.map { |arg| camel_case_symbols(arg) } } .map(&:join) end private + def get_values(value) if value.is_a?(Enumerable) - pairs = value.map { |k, v| + pairs = value.map do |k, v| KeyValuePair.new(k, v) - } + end return Array.new(pairs) if value.is_a?(Array) pairs else Value.new(value)