lib/apia/route_set.rb
# Add a new route to the set
#
# @param route [Moonstone::Route]
# @return [Moonstone::Route]
Add a new route to the set
Add a new route to the set
def add(route)
      @routes << route
      if route.controller && !@controllers.include?(route.controller)
        @controllers << route.controller
      end
      if route.endpoint && !@controllers.include?(route.endpoint)
        @endpoints << route.endpoint
      end
      parts = self.class.split_path(route.path).map { |p| p =~ /\A:/ ? '?' : p }
      parts.size.times do |i|
        if i.zero?
          source = @map
        else
          source = @map.dig(*parts[0, i])
        end
        source[parts[i]] ||= { _routes: [] }
        source[parts[i]][:_routes] << route if i == parts.size - 1
      end
      route
    end
def add ( route ) @routes << route if route . controller && ! @controllers . include? ( route . controller ) @controllers << route . controller end if route . endpoint && ! @controllers . include? ( route . endpoint ) @endpoints << route . endpoint end parts = self . class . split_path ( route . path ) . map { | p | p =~ / \A : / ? '?' : p } parts . size . times do | i | if i . zero? source = @map else source = @map . dig ( * parts [ 0 , i ] ) end source [ parts [ i ] ] ||= { _routes : [ ] } source [ parts [ i ] ] [ :_routes ] << route if i == parts . size - 1 end route end
Add a new route to the set
Add a new route to the set
None
Moonstone::Route
route
<not_specific>
<not_specific>
None