NamespacedGenerator
# File lib/generators/resource_controller.rb, line 53 def add_resource_route(plural_resource) router_path = Merb.root + "/config/router.rb" sentinel = "Merb::Router.prepare do" to_inject = "resources :#{plural_resource}" if File.exist?(router_path) content = File.read(router_path).gsub(/(#{Regexp.escape(sentinel)})/i){|match| "#{match}\n #{to_inject}"} File.open(router_path, 'wb') { |file| file.write(content) } end end
# File lib/generators/resource_controller.rb, line 63 def model_class_name class_name.singularize end
TODO: fix this for Datamapper, so that it returns the primary keys for the model
# File lib/generators/resource_controller.rb, line 80 def params_for_get "params[:id]" end
# File lib/generators/resource_controller.rb, line 67 def plural_model class_name.snake_case end
TODO: implement this for Datamapper so that we get the model properties
# File lib/generators/resource_controller.rb, line 85 def properties [] end
# File lib/generators/resource_controller.rb, line 75 def resource_path chunks.map{ |c| c.snake_case }.join('/') end
Generated with the Darkfish Rdoc Generator 2.