Module: Goldberg::Routes

Defined in:
lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb', line 4

def self.included(base)
  base.class_eval do
    alias_method :draw_without_goldberg_routes, :draw
    alias_method :draw, :draw_with_goldberg_routes
  end
end

Instance Method Details

#draw_with_goldberg_routes(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb', line 11

def draw_with_goldberg_routes(&block)
  
  draw_without_goldberg_routes do |map|
    block.call map 
  end

  routes = [ 
            ['', 
             {:controller => "goldberg/content_pages",
               :action => "view_default"}],

            ['menu/*name', 
             {:controller => 'goldberg/menu_items', :action => 'link'}],

            ['*page_name', 
             {:controller => "goldberg/content_pages", :action => "view"}]
           ]

  route_method = ActionController::Routing::Routes.respond_to?(:add_route)? 
  :add_route : :connect

  for route in routes do
    ActionController::Routing::Routes.send(route_method, *route)
  end

  # Install the new routes (Rails 1.1 only)
  if ActionController::Routing::Routes.respond_to? :write_generation and
      ActionController::Routing::Routes.respond_to? :write_recognition
    ActionController::Routing::Routes.write_generation
    ActionController::Routing::Routes.write_recognition
  end 
end