Class: Jax::Generators::Controller::ControllerGenerator
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#check_plugin_destination
inherited
Methods included from Usage
extended, included
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ ControllerGenerator
Returns a new instance of ControllerGenerator.
15
16
17
18
19
20
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 15
def initialize(args=[], options={}, config={})
super
@actions = args[1..-1].collect { |c| c.underscore }
@actions = ['index'] if @actions.empty?
@controller_name = controller_name.underscore
end
|
Instance Attribute Details
#action_name ⇒ Object
Returns the value of attribute action_name.
8
9
10
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 8
def action_name
@action_name
end
|
#actions ⇒ Object
Returns the value of attribute actions.
8
9
10
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 8
def actions
@actions
end
|
Class Method Details
.source_root ⇒ Object
11
12
13
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 11
def self.source_root
File.expand_path("templates", File.dirname(__FILE__))
end
|
Instance Method Details
#helper ⇒ Object
26
27
28
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 26
def helper
template 'helper.js.tt', File.join("app/helpers", "#{file_name}_helper.js")
end
|
#root_route ⇒ Object
49
50
51
52
53
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 49
def root_route
if options[:root]
insert_into_file "config/routes.rb", " root '#{controller_name}'\n", :before => /^end\s*\Z/
end
end
|
#routes ⇒ Object
42
43
44
45
46
47
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 42
def routes
actions.each do |action|
insert_into_file "config/routes.rb", "\n map '#{controller_name}/#{action}'",
:after => /\.routes\.map do$/
end
end
|
#source ⇒ Object
22
23
24
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 22
def source
template 'controller_source.js.tt', File.join("app/controllers", "#{file_name}_controller.js")
end
|
#tests ⇒ Object
30
31
32
33
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 30
def tests
template 'controller_test.js.tt', File.join('spec/javascripts/controllers', "#{file_name}_controller_spec.js")
template 'helper_test.js.tt', File.join('spec/javascripts/helpers', "#{file_name}_helper_spec.js")
end
|
#views ⇒ Object
35
36
37
38
39
40
|
# File 'lib/jax/generators/controller/controller_generator.rb', line 35
def views
actions.each do |action|
@action_name = action
template 'view.js.tt', File.join("app/views", file_name, "#{action}.js")
end
end
|