Sha256: c918a95c1b04d26949a885f1b535ad30cb4e1910be91bb3a87a5d54006fd2d57
Contents?: true
Size: 698 Bytes
Versions: 3
Compression:
Stored size: 698 Bytes
Contents
# frozen_string_literal: true module Remocon module ParameterSorter PARAMETER_KEYS = %i(description value file normalizer conditions options).freeze def sort_parameters(parameters) arr = parameters.sort.map do |k, v| hash_arr = v.symbolize_keys.sort { |(a, _), (b, _)| PARAMETER_KEYS.index(a) <=> PARAMETER_KEYS.index(b) } .map do |k1, v1| { k1 => k1.to_sym == :conditions ? sort_parameters(v1) : v1 } 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
remocon-0.4.1 | lib/remocon/sorter/parameter_sorter.rb |
remocon-0.4.0 | lib/remocon/sorter/parameter_sorter.rb |
remocon-0.4.0.pre.1 | lib/remocon/sorter/parameter_sorter.rb |