# File lib/generators/resource_controller.rb, line 53 53: def add_resource_route(plural_resource) 54: router_path = Merb.root + "/config/router.rb" 55: sentinel = "Merb::Router.prepare do" 56: to_inject = "resources :#{plural_resource}" 57: if File.exist?(router_path) 58: content = File.read(router_path).gsub(/(#{Regexp.escape(sentinel)})/i){|match| "#{match}\n #{to_inject}"} 59: File.open(router_path, 'wb') { |file| file.write(content) } 60: end 61: end
# File lib/generators/resource_controller.rb, line 63 63: def model_class_name 64: class_name.singularize 65: end
TODO: fix this for Datamapper, so that it returns the primary keys for the model
# File lib/generators/resource_controller.rb, line 80 80: def params_for_get 81: "params[:id]" 82: end
# File lib/generators/resource_controller.rb, line 67 67: def plural_model 68: class_name.snake_case 69: end
TODO: implement this for Datamapper so that we get the model properties
# File lib/generators/resource_controller.rb, line 85 85: def properties 86: [] 87: end
# File lib/generators/resource_controller.rb, line 75 75: def resource_path 76: chunks.map{ |c| c.snake_case }.join('/') 77: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.