lib/dbee/key_chain.rb in dbee-2.1.1 vs lib/dbee/key_chain.rb in dbee-3.0.0

- old
+ new

@@ -36,7 +36,18 @@ def ancestor_path?(*parts) path = parts.flatten.compact.join(KeyPath::SPLIT_CHAR) ancestor_path_set.include?(path) end + + # Returns a unique set of ancestors by considering all column names to be the same. + def to_unique_ancestors # :nodoc: + normalized_paths = key_path_set.map do |kp| + KeyPath.new((kp.ancestor_names + COLUMN_PLACEHOLDER).join(KeyPath::SPLIT_CHAR)) + end + self.class.new(normalized_paths.uniq) + end + + COLUMN_PLACEHOLDER = ['any_column'].freeze + private_constant :COLUMN_PLACEHOLDER end end