Skip to content

Instantly share code, notes, and snippets.

@LoganBarnett
Created October 9, 2008 23:29
Show Gist options
  • Save LoganBarnett/15939 to your computer and use it in GitHub Desktop.
Save LoganBarnett/15939 to your computer and use it in GitHub Desktop.
def menu_for(controller_identifier, tab_item=nil)
if controller_identifier =~ /detailed_alarms/
return "configure_detailed_alarms_checkbox_menu_item"
end
tab_name = tab_item ? "_#{tab_item}_" : ''
choices = (self.methods - Object.methods).select {|m|
m =~ /action_performed/
}.select { |m| m =~ /#{controller_identifier}#{tab_name}/ }
raise "menu handler trouble for '#{controller_identifier}:\n #{choices.inspect}'" if choices.empty? || choices.size > 1
choices.first.sub('_action_performed', '')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment