class MenuMaker::MenuRenderer
Attributes
current_path[R]
h[R]
helpers[R]
Public Class Methods
new(helpers, path = nil)
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 16 def initialize(helpers, path = nil) @helpers = helpers @current_path = find_current_path(path) end
render(&block)
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 8 def self.render(&block) define_method :render do build_html do instance_eval(&block) end end end
Public Instance Methods
build_html() { |''| ... }
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 29 def build_html output = yield '' if output.respond_to? :html_safe output.html_safe else output end end
call(menu)
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 39 def call(menu) self.menu = menu render end
Private Instance Methods
find_current_path(current_path)
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 46 def find_current_path(current_path) Path::Converter.convert(current_path || request || '') end
helpers_has_request?()
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 50 def helpers_has_request? helpers.respond_to?(:request) end
request()
click to toggle source
# File lib/menu_maker/menu_renderer.rb, line 54 def request helpers.request if helpers_has_request? end