Sha256: c40855bf3b164400052d43690cb24e59de370a4eef5acc3379596fe282ebfc67
Contents?: true
Size: 680 Bytes
Versions: 1
Compression:
Stored size: 680 Bytes
Contents
# frozen_string_literal: true module Remocon module ParameterSorter PARAMETER_KEYS = %i[description value file normalizer conditions options] def sort_parameters(parameters) arr = parameters.sort.map do |k, v| hash_arr = v.sort { |(a, _), (b, _)| PARAMETER_KEYS.index(a) <=> PARAMETER_KEYS.index(b) } .map do |k, v| { k => k.to_sym == :conditions ? sort_parameters(v) : v } end { k => hash_arr.each_with_object({}) { |hash, acc| acc.merge!(hash) } } end arr.each_with_object({}) { |hash, acc| acc.merge!(hash) }.with_indifferent_access end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remocon-0.1.0 | lib/remocon/sorter/parameter_sorter.rb |