Class: ControllerGenerator

Inherits:
Genosaurus show all
Defined in:
lib/mack/generators/controller_generator/controller_generator.rb

Overview

Generates a controller for Mack applications.

Example:

rake generate:controller name=post # => Generates a PostsController that includes Mack::Controller.

Or you can get the generator to create some actions for you this way:

rake generator:controller name=post actions=index,show # => Generates a PostController with a placeholder for the index and show actions.

Finally, the controller generator includes a magic word for the actions parameter:

rake generator:controller name=post actions=restful # => Generates a PostsController with the 7 rest actions.

Instance Method Summary collapse

Methods inherited from Genosaurus

#before_generate, #copy, describe, description_detail, #directory, #generate, #initialize, #manifest, #manifest_path, #method_missing, #param, require_param, required_params, run, #template, #templates_directory_path

Constructor Details

This class inherits a constructor from Genosaurus

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Genosaurus

Instance Method Details

#after_generateObject

:nodoc:



28
29
30
31
32
# File 'lib/mack/generators/controller_generator/controller_generator.rb', line 28

def after_generate # :nodoc:
  add_actions
  update_routes_file
  ControllerHelperGenerator.run(@options)
end

#setupObject

:nodoc:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mack/generators/controller_generator/controller_generator.rb', line 15

def setup # :nodoc:
  @name_singular = param(:name).singular.underscore
  @name_plural = param(:name).plural.underscore
  @name_singular_camel = @name_singular.camelcase
  @name_plural_camel = @name_plural.camelcase
  @actions = []
  if param(:actions).to_s == "restful"
    @actions = %w{index show new edit create update destroy}
  else      
    @actions = param(:actions).split(",") unless param(:actions).blank?
  end
end