Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def menu_for(controller_identifier, tab_item=nil)
  2. if controller_identifier =~ /detailed_alarms/
  3. return "configure_detailed_alarms_checkbox_menu_item"
  4. end
  5.  
  6. tab_name = tab_item ? "_#{tab_item}_" : ''
  7. choices = (self.methods - Object.methods).select {|m|
  8. m =~ /action_performed/
  9. }.select { |m| m =~ /#{controller_identifier}#{tab_name}/ }
  10.  
  11. raise "menu handler trouble for '#{controller_identifier}:\n #{choices.inspect}'" if choices.empty? || choices.size > 1
  12. choices.first.sub('_action_performed', '')
  13. end
Add Comment
Please, Sign In to add comment