Class: Xmvc::Generator::Controller

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/xmvc/generators/controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



6
7
8
# File 'lib/xmvc/generators/controller.rb', line 6

def self.source_root 
  File.join(Xmvc::TEMPLATE_PATH)
end

Instance Method Details

#generate(name, *actions) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xmvc/generators/controller.rb', line 11

def generate(name, *actions)
  @name             = name
  @actions          = actions
  @package          = name.downcase
  @controller_name  = Extlib::Inflection.underscore(name)
  @filename         = "app/controllers/#{@controller_name}_controller.js"
  
  unless File.exists? @filename
    Xmvc::Config.add(:controllers, @controller_name)
  end
                
  template "Controller.js", @filename
end