Class: Apimaster::Generators::ControllerGenerator
- Defined in:
- lib/apimaster/generators/controller_generator.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Base
#active, #args, #destination_root, #logger, #source_root, #spec, #stdout
Attributes included from Options
Instance Method Summary collapse
-
#initialize(runtime_args, runtime_options = {}) ⇒ ControllerGenerator
constructor
A new instance of ControllerGenerator.
- #manifest ⇒ Object
Methods inherited from Create
#class_collisions, #complex_template, #directory, #file, #file_copy_each, #folder, #identical?, #migration_template, #readme, #route_resources, #template, #template_copy_each, #write_manifest
Methods inherited from Command
#class_collisions, #dependency, #destination_path, #invoke!, #readme, #source_path, #write_manifest
Methods inherited from Base
#after_generate, #base_name, #camelize, #destination_path, #pluralize, #run, #source_path
Methods included from Options
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ ControllerGenerator
Returns a new instance of ControllerGenerator.
6 7 8 9 10 11 12 13 |
# File 'lib/apimaster/generators/controller_generator.rb', line 6 def initialize(runtime_args, = {}) super raise 'Unknown app directory.' unless File.exists?('./Gemfile') @app_name = File.basename(File.('./')) @module_name = camelize(app_name) @name = args[0] raise 'Undefined app name.' unless @app_name end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/apimaster/generators/controller_generator.rb', line 4 def app_name @app_name end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
4 5 6 |
# File 'lib/apimaster/generators/controller_generator.rb', line 4 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/apimaster/generators/controller_generator.rb', line 4 def name @name end |
Instance Method Details
#manifest ⇒ Object
15 16 17 18 19 20 |
# File 'lib/apimaster/generators/controller_generator.rb', line 15 def manifest record do |m| m.template "app/controllers/examples_controller.rb.erb", "app/controllers/#{pluralize name}_controller.rb" m.template "test/functional/examples_controller_test.rb.erb", "test/functional/#{pluralize name}_controller_test.rb" end end |