lib/mongoid/path_extension.rb in mongoid-path_extension-0.1.2 vs lib/mongoid/path_extension.rb in mongoid-path_extension-0.1.3
- old
+ new
@@ -26,9 +26,18 @@
def has_parent?
components.length > 1
end
+ def ancestor_paths
+ return unless has_parent?
+ res = []
+ components[0..-2].each_with_index do |component, index|
+ res << components[0..index].join('/')
+ end
+ res
+ end
+
def parent_path
return unless has_parent?
components[0..-2].join('/')
end