Class: RailsUpgrade::Upgraders::RouteGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-upgrade/upgraders/routes.rb

Instance Method Summary collapse

Constructor Details

#initialize(routes) ⇒ RouteGenerator

Returns a new instance of RouteGenerator.



282
283
284
285
# File 'lib/rails-upgrade/upgraders/routes.rb', line 282

def initialize(routes)
  @routes = routes
  @new_code = ""
end

Instance Method Details

#generateObject



287
288
289
290
291
292
293
# File 'lib/rails-upgrade/upgraders/routes.rb', line 287

def generate
  @new_code = @routes.map do |r|
    r.to_route_code
  end.join("\n")
  
  "#{app_name.classify}::Application.routes do\n#{@new_code}\nend\n"
end