Class: Jax::Generators::ControllerGenerator

Inherits:
RailsBase
  • Object
show all
Defined in:
lib/generators/jax/controller/controller_generator.rb

Instance Method Summary collapse

Methods inherited from RailsBase

#initialize, rails_equivalent

Methods included from SourceRoot

#source_root

Methods included from CoffeeGenerator

included

Constructor Details

This class inherits a constructor from Jax::Generators::RailsBase

Instance Method Details

#add_index_actionObject



11
12
13
# File 'lib/generators/jax/controller/controller_generator.rb', line 11

def add_index_action
  actions.unshift 'index' unless actions.include?('index') or options[:without_index]
end

#create_controller_fileObject



15
16
17
18
# File 'lib/generators/jax/controller/controller_generator.rb', line 15

def create_controller_file
  coffee_template_with_fallback "controller.js",
    File.join('app/assets/jax/controllers', "#{file_name}_controller.js")
end

#create_spec_fileObject



20
21
22
23
# File 'lib/generators/jax/controller/controller_generator.rb', line 20

def create_spec_file
  coffee_template_with_fallback "controller_spec.js",
    File.join('spec/javascripts/jax/controllers', "#{file_name}_controller_spec.js")
end

#create_view_fileObject



25
26
27
28
29
30
31
# File 'lib/generators/jax/controller/controller_generator.rb', line 25

def create_view_file
  for action in actions
    @action_name = action
    coffee_template_with_fallback "view.js",
      File.join('app/assets/jax/views', file_name, "#{action}.js")
  end
end