Sha256: af0950b5d04dd9cb75bc58ca1332bdf86d8c3cb0eda0827e46a05614cd4d3bd3
Contents?: true
Size: 706 Bytes
Versions: 3
Compression:
Stored size: 706 Bytes
Contents
# frozen_string_literal: true # Convert Hash with mixed array and hash values to an # array of paths. module Runger::Ext::FlattenNames refine ::Array do def flatten_names(prefix, buf) if empty? buf << :"#{prefix}" return buf end each_with_object(buf) do |name, acc| if name.is_a?(::Symbol) acc << :"#{prefix}.#{name}" else name.flatten_names(prefix, acc) end end end end refine ::Hash do def flatten_names(prefix = nil, buf = []) each_with_object(buf) do |(k, v), acc| parent = prefix ? "#{prefix}.#{k}" : k v.flatten_names(parent, acc) end end end using self end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
runger_config-5.2.0 | lib/runger/ext/flatten_names.rb |
runger_config-5.1.0 | lib/runger/ext/flatten_names.rb |
runger_config-5.0.0 | lib/runger/ext/flatten_names.rb |