Parent

Padrino::Generators::Controller

Responsible for generating route controllers and associated tests within a Padrino application.

Public Class Methods

source_root() click to toggle source

Define the source template root

# File lib/padrino-gen/generators/controller.rb, line 12
def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Public Instance Methods

create_controller() click to toggle source

Execute controller generation

@api private

# File lib/padrino-gen/generators/controller.rb, line 35
def create_controller
  self.destination_root = options[:root]
  if in_app_root?
    app = options[:app]
    check_app_existence(app)
    @app_name = fetch_app_name(app)
    @actions  = controller_actions(fields)
    @controller = name.to_s.underscore
    self.behavior = :revoke if options[:destroy]
    template "templates/controller.rb.tt", destination_root(app, "controllers", "#{name.to_s.underscore}.rb")
    template "templates/helper.rb.tt",     destination_root(app, "helpers", "#{name.to_s.underscore}_helper.rb")
    empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
    include_component_module_for(:test)
    generate_controller_test(name) if test?
  else
    say "You are not at the root of a Padrino application! (config/boot.rb not found)"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.