Sha256: 52761ad3b112de3cdf143bfe71323a1ebce9885073037409e8696689fc5a050d
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
Rails::Generator::Commands::Create.class_eval do def route_resource(*resources) resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') sentinel = 'ActionController::Routing::Routes.draw do |map|' logger.route "map.resource #{resource_list}" unless options[:pretend] gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n map.resource #{resource_list}\n" end end end def route_name(name, path, options = {}) sentinel = 'ActionController::Routing::Routes.draw do |map|' logger.route "map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'" unless options[:pretend] gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'" end end end end Rails::Generator::Commands::Destroy.class_eval do def route_resource(*resources) resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') look_for = "\n map.resource #{resource_list}\n" logger.route "map.resource #{resource_list}" gsub_file 'config/routes.rb', /(#{look_for})/mi, '' end def route_name(name, path, options = {}) look_for = "\n map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'" logger.route "map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'" gsub_file 'config/routes.rb', /(#{look_for})/mi, '' end end Rails::Generator::Commands::List.class_eval do def route_resource(*resources) resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') logger.route "map.resource #{resource_list}" end def route_name(name, path, options = {}) logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'" end end
Version data entries
5 entries across 5 versions & 2 rubygems