Class: ActivityNotification::Generators::ControllersGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActivityNotification::Generators::ControllersGenerator
- Defined in:
- lib/generators/activity_notification/controllers_generator.rb
Overview
Controller generator to create customizable controller files from templates.
Constant Summary collapse
- CONTROLLERS =
['notifications', 'notifications_with_devise', 'notifications_api', 'notifications_api_with_devise', 'subscriptions', 'subscriptions_with_devise', 'subscriptions_api', 'subscriptions_api_with_devise'].freeze
Instance Method Summary collapse
-
#create_controllers ⇒ Object
Creates controller files in application directory.
-
#show_readme ⇒ Object
Shows readme to console.
Instance Method Details
#create_controllers ⇒ Object
Creates controller files in application directory
35 36 37 38 39 40 41 42 |
# File 'lib/generators/activity_notification/controllers_generator.rb', line 35 def create_controllers @target_prefix = target.blank? ? '' : (target.camelize + '::') controllers = [:controllers] || CONTROLLERS controllers.each do |name| template "#{name}_controller.rb", "app/controllers/#{target}/#{name}_controller.rb" end end |
#show_readme ⇒ Object
Shows readme to console
45 46 47 |
# File 'lib/generators/activity_notification/controllers_generator.rb', line 45 def show_readme readme "README" if behavior == :invoke end |