/usr/lib/ruby/vendor_ruby/simple_navigation/core/items_provider.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 30 31 32 33 34 35 | module SimpleNavigation
# Acts as a proxy to navigation items that are passed into the SimpleNavigation::Configuration#items method. It hides the logic
# for finding items from the Configuration object.
#
class ItemsProvider
attr_reader :provider
# It accepts the following types of provider:
# * methodname as symbol - the specified method should return the relevant items and has to be available in the view (a helper method)
# * object that responds to :items
# * enumerable object that represents the items
#
# See SimpleNavigation::ItemAdapter for the requirements that need to be fulfilled by the provided items.
#
def initialize(provider)
@provider = provider
end
# Returns the navigation items
def items
if provider.instance_of?(Symbol)
SimpleNavigation.context_for_eval.send(provider)
elsif provider.respond_to?(:items)
provider.items
elsif provider.respond_to?(:each)
provider
else
raise "items_provider either must be a symbol specifying the helper-method to call, an object with an items-method defined or an enumerable representing the items"
end
end
end
end
|