Module: PartialFinder::Router
- Defined in:
- lib/partial_finder/router.rb
Class Method Summary collapse
- .routes ⇒ Object
-
.routes_from(controller_sig) ⇒ Object
Input string must be in the format controller_name#method, ie “users_controller#create”.
Class Method Details
.routes ⇒ Object
3 4 5 |
# File 'lib/partial_finder/router.rb', line 3 def self.routes @@routes ||= `rake routes` end |
.routes_from(controller_sig) ⇒ Object
Input string must be in the format controller_name#method, ie “users_controller#create”. Returns a list of strings that correspond to the routes that point to the given controller.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/partial_finder/router.rb', line 11 def self.routes_from(controller_sig) entries = routes .scan(/^.+ \/(.+)\(\.:format\) +(#{controller_sig})/) .first if entries.present? entries .reject{ |a| a == controller_sig } .map{ |a| "/#{a}" } else [] end end |