module ExtJS module MVC module Generator class Controller < Base def initialize(name, actions = []) super @name = name @actions = actions @package = name.downcase @gsubs.merge!({ 'controller_name' => "#{name.capitalize}Controller", 'short_name' => @package, 'actions' => generate_actions }) @controller_filename = "app/controllers/#{@gsubs['controller_name']}.js" end def generate! ensure_no_overwrite! @controller_filename ensure_directories_present! "app", "app/controllers" template "Controller.js", @controller_filename generate_views! end private def generate_actions @actions.collect {|act| render_template("_Action.js", {'action_name' => act})}.join("") end def generate_views! @actions.each {|a| View.new(@package, a).generate!} end end end end end