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
-
#enable_effective_resources ⇒ Object
Find if effective_resources is in the app's Gemfile.
- #invoke_controller ⇒ Object
Instance Method Details
#assign_actions ⇒ Object
20 21 22 |
# File 'lib/generators/effective/controller_generator.rb', line 20 def assign_actions @actions = invoked_actions end |
#assign_attributes ⇒ Object
24 25 26 27 |
# File 'lib/generators/effective/controller_generator.rb', line 24 def assign_attributes @attributes = invoked_attributes.presence || (resource.belong_tos_attributes + resource_attributes) self.class.send(:attr_reader, :attributes) end |
#create_controller ⇒ Object
42 43 44 |
# File 'lib/generators/effective/controller_generator.rb', line 42 def create_controller template 'controllers/controller.rb', resource.controller_file end |
#enable_effective_resources ⇒ Object
Find if effective_resources is in the app's Gemfile
34 35 36 37 38 39 40 |
# File 'lib/generators/effective/controller_generator.rb', line 34 def enable_effective_resources self.class.send(:attr_reader, :use_effective_resources) Effective::CodeWriter.new('Gemfile') do |w| @use_effective_resources = w.find { |line| line.include?('effective_resources') }.present? end end |
#invoke_controller ⇒ Object
29 30 31 |
# File 'lib/generators/effective/controller_generator.rb', line 29 def invoke_controller say_status :invoke, :controller, :white end |