lib/i18n/tasks/data/tree/nodes.rb in i18n-tasks-0.5.4 vs lib/i18n/tasks/data/tree/nodes.rb in i18n-tasks-0.6.0
- old
+ new
@@ -21,11 +21,15 @@
def attributes
{nodes: @list}
end
def derive(new_attr = {})
- attr = attributes.merge(new_attr)
- attr[:nodes] ||= @list.map(&:derive)
+ attr = attributes.except(:nodes, :parent).merge(new_attr)
+ if self.parent
+ new_attr[:parent] ||= Node.null
+ end
+ node_attr = new_attr.slice(:parent)
+ attr[:nodes] ||= @list.map { |node| node.derive(node_attr) }
self.class.new(attr)
end
def to_hash
@hash ||= map(&:to_hash).reduce(:deep_merge!) || {}