Class: Effective::Generators::ControllerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/effective/controller_generator.rb

Instance Method Summary collapse

Instance Method Details

#assign_actionsObject



24
25
26
# File 'lib/generators/effective/controller_generator.rb', line 24

def assign_actions
  @actions = invoked_actions
end

#assign_attributesObject



28
29
30
31
# File 'lib/generators/effective/controller_generator.rb', line 28

def assign_attributes
  @attributes = invoked_attributes.presence || resource.belong_tos_attributes.merge(resource_attributes)
  self.class.send(:attr_reader, :attributes)
end

#create_controllerObject



37
38
39
40
41
42
43
44
# File 'lib/generators/effective/controller_generator.rb', line 37

def create_controller
  if admin_effective_scaffold?
    template "#{scaffold_path}/controllers/controller.rb", resource.admin_effective_controller_file
  else
    template "#{scaffold_path}/controllers/controller.rb", resource.controller_file
  end

end

#invoke_controllerObject



33
34
35
# File 'lib/generators/effective/controller_generator.rb', line 33

def invoke_controller
  say_status :invoke, :controller, :white
end

#validate_resourceObject



20
21
22
# File 'lib/generators/effective/controller_generator.rb', line 20

def validate_resource
  exit unless resource_valid?
end