Merb::Generators::ResourceControllerGenerator

Public Class Methods

source_root() click to toggle source
   # File lib/generators/resource_controller.rb, line 5
5:     def self.source_root
6:       File.join(super, 'component', 'resource_controller')
7:     end

Public Instance Methods

add_resource_route(plural_resource) click to toggle source
    # 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
model_class_name() click to toggle source
    # File lib/generators/resource_controller.rb, line 63
63:     def model_class_name
64:       class_name.singularize
65:     end
params_for_get() click to toggle source

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
plural_model() click to toggle source
    # File lib/generators/resource_controller.rb, line 67
67:     def plural_model
68:       class_name.snake_case
69:     end
properties() click to toggle source

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
resource_path() click to toggle source
    # File lib/generators/resource_controller.rb, line 75
75:     def resource_path
76:       chunks.map{ |c| c.snake_case }.join('/')
77:     end
singular_model() click to toggle source
    # File lib/generators/resource_controller.rb, line 71
71:     def singular_model
72:       plural_model.singularize
73:     end
skip_route_definition?() click to toggle source
    # File lib/generators/resource_controller.rb, line 89
89:     def skip_route_definition?
90:       options[:pretend] || options[:delete]
91:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.