15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/objects/config_factory.rb', line 15
def add_crumbs(crumbs, data)
views = @tree
number_crumbs = crumbs.size
crumbs.each_with_index do |crumb, index|
is_last_crumb = number_crumbs == (index + 1)
if this_view = hash_for_identifier_from_view(crumb, views)
views = this_view
else
this_view = { identifier: crumb }
this_view[:views] = [] unless is_last_crumb && data[:type].to_sym == :inventory
views[:views] << this_view
views = hash_for_identifier_from_view(crumb, views)
end
this_view.merge!(data) if is_last_crumb
end
end
|