Class: Cubic::Generator::Controller

Inherits:
Base
  • Object
show all
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

#files

Instance Method Summary collapse

Methods inherited from Base

#generate

Constructor Details

#initializeController

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, options = {})
  if options[:actions] && options[:actions].any?
    actions = options[:actions]
    create_views(name, actions)
  else
    actions = []
  end

  @files << { name: "#{name}_controller.rb",
              path: '/app/controllers/',
              content: build_controller(name, actions) }
  self
end