/usr/lib/ruby/vendor_ruby/simple_navigation/rendering/renderer/json.rb is in ruby-simple-navigation 3.11.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | module SimpleNavigation
module Renderer
# Renders the navigation items as a object tree serialized as a json string, can also output raw ruby Hashes
class Json < SimpleNavigation::Renderer::Base
def render(item_container)
results = hash_render(item_container)
results = results.to_json unless options[:as_hash]
results
end
private
def hash_render(item_container)
return nil if item_container.nil?
item_container.items.map do |item|
item_hash = {
:name => item.name,
:url => item.url,
:selected => item.selected?,
:items => hash_render(item.sub_navigation)
}
end
end
end
end
end
|