changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/restful_authentication/lib/restful_authentication/rails_commands.rb

changeset 4: 43c5e6930eee
author: moriq@moriq.com
date: Wed Mar 05 01:17:41 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugin restful_authentication.
1Rails::Generator::Commands::Create.class_eval do
2 def route_resource(*resources)
3 resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
4 sentinel = 'ActionController::Routing::Routes.draw do |map|'
5
6 logger.route "map.resource #{resource_list}"
7 unless options[:pretend]
8 gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
9 "#{match}\n map.resource #{resource_list}\n"
10 end
11 end
12 end
13end
14
15Rails::Generator::Commands::Destroy.class_eval do
16 def route_resource(*resources)
17 resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
18 look_for = "\n map.resource #{resource_list}\n"
19 logger.route "map.resource #{resource_list}"
20 gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
21 end
22end
23
24Rails::Generator::Commands::List.class_eval do
25 def route_resource(*resources)
26 resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
27 logger.route "map.resource #{resource_list}"
28 end
29end