Class: Effective::Generators::ControllerGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::ControllerGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/controller_generator.rb
Instance Method Summary collapse
- #assign_actions ⇒ Object
- #assign_attributes ⇒ Object
- #create_controller ⇒ Object
- #invoke_controller ⇒ Object
- #validate_resource ⇒ Object
Instance Method Details
#assign_actions ⇒ Object
24 25 26 |
# File 'lib/generators/effective/controller_generator.rb', line 24 def assign_actions @actions = invoked_actions end |
#assign_attributes ⇒ Object
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_controller ⇒ Object
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_controller ⇒ Object
33 34 35 |
# File 'lib/generators/effective/controller_generator.rb', line 33 def invoke_controller say_status :invoke, :controller, :white end |
#validate_resource ⇒ Object
20 21 22 |
# File 'lib/generators/effective/controller_generator.rb', line 20 def validate_resource exit unless resource_valid? end |