Method: Camping::CommandsHelpers::RoutesParser#parse

Defined in:
lib/camping/commands.rb

#parseObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# 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