lib/simple_navigation.rb in simple-navigation-2.1.0 vs lib/simple_navigation.rb in simple-navigation-2.2.0
- old
+ new
@@ -53,11 +53,26 @@
# Returns nil if there is no current navigation set for level.
def current_navigation_for(level)
self.controller.instance_variable_get(:"@sn_current_navigation_#{level}")
end
+ # Returns the active item container for the specified level. Valid levels are
+ # * :all - in this case the primary_navigation is returned.
+ # * a specific level - the active item_container for the specified level will be returned
+ # * a range of levels - the active item_container for the range's minimum will be returned
+ #
+ # Returns nil if there is no active item_container for the specified level.
def active_item_container_for(level)
- self.primary_navigation.active_item_container_for(level)
+ case level
+ when :all
+ self.primary_navigation
+ when Integer
+ self.primary_navigation.active_item_container_for(level)
+ when Range
+ self.primary_navigation.active_item_container_for(level.min)
+ else
+ raise ArgumentError, "Invalid navigation level: #{level}"
+ end
end
# If any navigation has been explicitely set in the controller this method evaluates the specified args set in the controller and sets
# the correct instance variable in the controller.
def handle_explicit_navigation
\ No newline at end of file