Class: StrongRoutes::Rails::RouteMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/strong_routes/rails/route_mapper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_set) ⇒ RouteMapper

Returns a new instance of RouteMapper.



13
14
15
# File 'lib/strong_routes/rails/route_mapper.rb', line 13

def initialize(route_set)
  @route_set = route_set
end

Instance Attribute Details

#route_setObject (readonly)

Returns the value of attribute route_set.



6
7
8
# File 'lib/strong_routes/rails/route_mapper.rb', line 6

def route_set
  @route_set
end

Class Method Details

.map(route_set) ⇒ Object



8
9
10
11
# File 'lib/strong_routes/rails/route_mapper.rb', line 8

def self.map(route_set)
  route_mapper = self.new(route_set)
  route_mapper.map
end

Instance Method Details

#mapObject

Map the route set to a collection of the top level segments.



18
19
20
21
22
23
# File 'lib/strong_routes/rails/route_mapper.rb', line 18

def map
  map = matches.map { |match_data| match_data[:path] }
  map.compact!
  map.uniq!
  map
end