Class: ActionController::Routing::RouteSet

Inherits:
Object
  • Object
show all
Defined in:
lib/productize.rb

Instance Method Summary collapse

Instance Method Details

#draw_append {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



82
83
84
85
86
# File 'lib/productize.rb', line 82

def draw_append
  yield self
  write_generation
  write_recognition
end

#reloadObject

Get both the base routes.rb file AND the site-specific routes.rb file



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/productize.rb', line 89

def reload
  NamedRoutes.clear

  loaded_routes = false

  # Load the initial set of routes for the base application
  if defined?(RAILS_ROOT) and File.exist?(File.join(RAILS_ROOT, 'config', 'routes.rb'))
    load(File.join(RAILS_ROOT, 'config', 'routes.rb'))
    loaded_routes = true
  end

  # Add on site-specific routes
  if defined?(SITE_ROOT) and File.exist?(File.join(SITE_ROOT, 'config', 'routes.rb'))
    load(File.join(SITE_ROOT, 'config', 'routes.rb'))
    loaded_routes = true
  end

  # Use a sensible default if nothing could be loaded
  unless loaded_routes
    connect(':controller/:action/:id', :action => 'index', :id => nil)
  end

  NamedRoutes.install
end

#replace(*args) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/productize.rb', line 73

def replace(*args)
  new_route = Route.new(*args)
  # Remove the old route that we're replacing
  @routes.delete_if { |r| r.path == args[0] }
  # Add the new one back
  @routes << new_route
  return new_route
end