# class Camping::CommandsHelpers::RoutesParser

### Public Class Methods

new(app = Camping) click to toggle source

    # File lib/camping/commands.rb, line 100
    def initialize(app = Camping)
      @parent_app, @routes = app, []
    end

parse(app) click to toggle source

    # File lib/camping/commands.rb, line 96
    def self.parse(app)
      new(app).parse
    end

### Public Instance Methods

parse() click to toggle source

    # File lib/camping/commands.rb, line 104
    def parse
      routes = @parent_app.make_camp
      collected_routes = []

      make_routes = -> (a) {

        a::X.all.map {|c|
          k = a::X.const_get(c)
          im = k.instance_methods(false).map!(&:to_s)
          methods = im & ["get", "post", "put", "patch", "delete"]
          if k.respond_to?:urls
            methods.each { |m|
              k.urls.each { |u|
                collected_routes.append Camping::CommandsHelpers::Route.new(m,c,a.to_s,u)
              }
            }
          end
        }
      }

      if @parent_app == Camping
        @parent_app::Apps.each {|a|
          make_routes.(a)
        }
      else
        make_routes.(@parent_app)
      end

      routes_collection = Camping::CommandsHelpers::RouteCollection.new(collected_routes)
    end