Class: ActivityNotification::Generators::ModelsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ActivityNotification::Generators::ModelsGenerator
- Defined in:
- lib/generators/activity_notification/models_generator.rb
Overview
Notification generator to create customizable notification model from templates.
Constant Summary collapse
- MODELS =
['notification', 'subscription'].freeze
Instance Method Summary collapse
-
#create_models ⇒ Object
Create notification model in application directory.
-
#show_readme ⇒ Object
Shows readme to console.
Instance Method Details
#create_models ⇒ Object
Create notification model in application directory
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/activity_notification/models_generator.rb', line 36 def create_models @target_prefix = target.blank? ? '' : (target.camelize + '::') models = [:models] || MODELS model_names = [:names] || MODELS models.zip(model_names).each do |original_name, new_name| @model_name = new_name.camelize template "#{original_name}.rb", "app/models/#{target}/#{@model_name.underscore}.rb" end end |
#show_readme ⇒ Object
Shows readme to console
48 49 50 |
# File 'lib/generators/activity_notification/models_generator.rb', line 48 def show_readme readme "README" if behavior == :invoke end |