Sha256: c4a4ef950c960870bf570fba179316d3e25ab833d32540242e4b214655c206a4

Contents?: true

Size: 1.35 KB

Versions: 97

Compression:

Stored size: 1.35 KB

Contents

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

    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

  end
end

ActionController::Routing::RouteSet.class_eval do
  include Goldberg::Routes
end

Version data entries

97 entries across 97 versions & 2 rubygems

Version Path
six-updater-web-0.24.15 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.14 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.13 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.12 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.11 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.10 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.9 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.8 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.7 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.6 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.5 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.4 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.3 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.2 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.1 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.24.0 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.23.7 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.23.6 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.23.5 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb
six-updater-web-0.23.4 lib/six-updater-web/vendor/plugins/goldberg/lib/goldberg/routes.rb