Class | SimpleNavigation::ItemsProvider |
In: |
lib/simple_navigation/core/items_provider.rb
|
Parent: | Object |
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.
provider | [R] |
It accepts the following types of provider:
See SimpleNavigation::ItemAdapter for the requirements that need to be fulfilled by the provided items.
# File lib/simple_navigation/core/items_provider.rb, line 17 def initialize(provider) @provider = provider end
Returns the navigation items
# File lib/simple_navigation/core/items_provider.rb, line 22 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