Class: RailsUpgrade::Upgraders::FakeNamespace

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RouteObject

#indent_lines, #opts_to_string

Constructor Details

#initialize(name) ⇒ FakeNamespace

Returns a new instance of FakeNamespace.



157
158
159
160
161
# File 'lib/rails-upgrade/upgraders/routes.rb', line 157

def initialize(name)
  @routes = []
  @name = name
  @indent = RouteRedrawer.indent
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



155
156
157
# File 'lib/rails-upgrade/upgraders/routes.rb', line 155

def name
  @name
end

#routesObject

Returns the value of attribute routes.



155
156
157
# File 'lib/rails-upgrade/upgraders/routes.rb', line 155

def routes
  @routes
end

Instance Method Details

#<<(val) ⇒ Object



169
170
171
# File 'lib/rails-upgrade/upgraders/routes.rb', line 169

def <<(val)
  @routes << val
end

#lastObject



173
174
175
# File 'lib/rails-upgrade/upgraders/routes.rb', line 173

def last
  @routes.last
end

#to_route_codeObject



163
164
165
166
167
# File 'lib/rails-upgrade/upgraders/routes.rb', line 163

def to_route_code
  lines = ["namespace :#{@name} do", @routes.map {|r| r.to_route_code}, "end"]
  
  indent_lines(lines)
end