class LieutenantGovernor::Routing::Extractor
Attributes
routes[R]
Public Class Methods
extract(routes)
click to toggle source
Takes applications routes and converts to hash @param [ActionDispatch::Routing::RouteSet] @return [Hash] table mapping names to paths
# File lib/lieutenant_governor/routing/extractor.rb, line 14 def self.extract(routes) instance = new(routes) instance.extract end
new(routes)
click to toggle source
# File lib/lieutenant_governor/routing/extractor.rb, line 19 def initialize(routes) @routes = routes end
Public Instance Methods
extract()
click to toggle source
# File lib/lieutenant_governor/routing/extractor.rb, line 23 def extract table = {} # possible to get blank strings as keys here routes.reduce(table) do |memo, obj| name = get_name(obj) path = get_path(obj) table[name] = path if name.length > 0 && path.length > 0 end table end
Private Instance Methods
get_name(obj)
click to toggle source
@param [ActionDispatch::Routing::Journey]
# File lib/lieutenant_governor/routing/extractor.rb, line 38 def get_name(obj) wrap(obj).name.camelcase end
get_path(obj)
click to toggle source
@param [ActionDispatch::Routing::Journey]
# File lib/lieutenant_governor/routing/extractor.rb, line 43 def get_path(obj) wrap(obj).path.split('(.:format)')[0] end
wrap(obj)
click to toggle source
@param [ActionDispatch::Routing::Journey]
# File lib/lieutenant_governor/routing/extractor.rb, line 48 def wrap(obj) ActionDispatch::Routing::RouteWrapper.new(obj) end