I have an array of rake routes, and I am trying to extract all of the routes which have route.conditions[:request_method] as GET.
Problems:
:request_method is a regex (:request_method=>/^GET$/)
> routes.select { |route| route.conditions[:request_method] == /GET/ }
> []
I figured my select was correct. This works, and outputs all route methods:
> routes.each { |route| print route.conditions[:request_method] }
> {:request_method=>/^GET$/}{:request_method=>/^GET$/}{:request_method=>/^PUT$/}{:request_method=>/^GET$/}{:request_method=>/^PUT$/}{:request_method=>/^POST$/}{:request_method=>/^GET$/}{:request_method=>/^GET$/}
Any ideas how I might achieve this?
Found my answer. routes.each was returning the Journey object, so I first created my own custom hash:
I’m sure this can be more elegantly reworked so I’m open to changes. It works, that’s the most important part.