Module: Rooftop::Rails::MenuHelper
- Defined in:
- app/helpers/rooftop/rails/menu_helper.rb
Instance Method Summary collapse
-
#path_for_menu_item(item) ⇒ Object
Given a Rooftop::Menus::Item, return a path for it, or nil if we can’t.
- #path_matches?(path) ⇒ Boolean
Instance Method Details
#path_for_menu_item(item) ⇒ Object
Given a Rooftop::Menus::Item, return a path for it, or nil if we can’t.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/rooftop/rails/menu_helper.rb', line 6 def (item) begin # for links elsewhere, return the url as-is if item.object_type == "custom" return item.url end # otherwise we need to determine if we have a nested resource if item.object_ancestor_slugs.present? # we have a nested tree of slugs resource_id = item.object_ancestor_slugs.split(",").push(item.object_slug).join("/") else resource_id = item.object_slug end return Rooftop::Rails::RouteResolver.new(item.object_type, resource_id).resolve rescue nil end end |
#path_matches?(path) ⇒ Boolean
27 28 29 |
# File 'app/helpers/rooftop/rails/menu_helper.rb', line 27 def path_matches?(path) request.url =~ %r{#{path}} end |