Created
October 9, 2008 23:29
-
-
Save LoganBarnett/15939 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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