1
0

Fixed Quantity defaults import after removing :name uniqueness

Added awesome_nested_set #each_with_path
This commit is contained in:
cryptogopher
2020-06-20 00:52:37 +02:00
parent 61498018e7
commit 4df88598f8
6 changed files with 35 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
module BodyTracking::AwesomeNestedSetPatch
CollectiveIdea::Acts::NestedSet.class_eval do
module CollectiveIdea::Acts::NestedSet
class Iterator
def each_with_path
return to_enum(__method__) { objects.length } unless block_given?
path = [nil]
objects.each do |o|
path[path.rindex(o.parent)+1..-1] = o
yield [o, path.map { |q| q.try(:name) }.join('::')]
end
end
end
module Model
module ClassMethods
def each_with_path(objects, &block)
Iterator.new(objects).each_with_path(&block)
end
end
end
end
end
end