Class: RailsUpgrade::Upgraders::FakeRoute
- Inherits:
-
RouteObject
- Object
- RouteObject
- RailsUpgrade::Upgraders::FakeRoute
- Defined in:
- lib/rails-upgrade/upgraders/routes.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, options, name = "") ⇒ FakeRoute
constructor
A new instance of FakeRoute.
- #to_route_code ⇒ Object
Methods inherited from RouteObject
#indent_lines, #opts_to_string
Constructor Details
#initialize(path, options, name = "") ⇒ FakeRoute
Returns a new instance of FakeRoute.
181 182 183 184 185 186 |
# File 'lib/rails-upgrade/upgraders/routes.rb', line 181 def initialize(path, , name = "") @path = path @options = || {} @name = name @indent = RouteRedrawer.indent end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
179 180 181 |
# File 'lib/rails-upgrade/upgraders/routes.rb', line 179 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
179 180 181 |
# File 'lib/rails-upgrade/upgraders/routes.rb', line 179 def @options end |
#path ⇒ Object
Returns the value of attribute path.
179 180 181 |
# File 'lib/rails-upgrade/upgraders/routes.rb', line 179 def path @path end |
Instance Method Details
#to_route_code ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/rails-upgrade/upgraders/routes.rb', line 188 def to_route_code if @options[:default_route] indent_lines ["match '#{@path}'"] else base = "match '%s' => '%s#%s'" = [] if not name.empty? << ":as => :#{name}" end if @options[:requirements] @options[:constraints] = @options.delete(:requirements) end if @options[:conditions] @options[:via] = @options.delete(:conditions).delete(:method) end @options ||= {} base = (base % [@path, @options.delete(:controller), (@options.delete(:action) || "index")]) opts = opts_to_string(@options) route_pieces = ([base] + + [opts]) route_pieces.delete("") indent_lines [route_pieces.join(", ")] end end |