Class: Cubic::Generator::Controller
- Defined in:
- lib/cubic/generators/controller.rb
Overview
Controller fulfils the C in the MVC pattern. Files the Model generator creates will include a class inheriting from the CubicController.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#design(name, options = {}) ⇒ Object
Creates a hash that will be used for file generation purposes.
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
Methods inherited from Base
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
7 8 9 10 |
# File 'lib/cubic/generators/controller.rb', line 7 def initialize @view = View.new super() end |
Instance Method Details
#design(name, options = {}) ⇒ Object
Creates a hash that will be used for file generation purposes
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cubic/generators/controller.rb', line 13 def design(name, = {}) if [:actions] && [:actions].any? actions = [:actions] create_views(name, actions) else actions = [] end @files << { name: "#{name}_controller.rb", path: '/app/controllers/', content: build_controller(name, actions) } self end |