Class: NotifyWith::NotificationGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- NotifyWith::NotificationGenerator
- Defined in:
- lib/generators/notify_with/notification/notification_generator.rb
Instance Method Summary collapse
- #add_notification_subject ⇒ Object
- #add_notification_type ⇒ Object
- #create_notification_json_template_file ⇒ Object
- #create_notification_mail_template_file ⇒ Object
Instance Method Details
#add_notification_subject ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/generators/notify_with/notification/notification_generator.rb', line 18 def add_notification_subject inject_into_file "config/locales/#{I18n.locale.to_s}.yml", after: /send_mail_by:\n/ do " subject_\#{file_name}: \"\#{file_name}\"\n" end end |
#add_notification_type ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/generators/notify_with/notification/notification_generator.rb', line 2 def add_notification_type inject_into_file 'app/models/notification_type.rb', before: / \)/ do " \#{file_name}\n" end end |
#create_notification_json_template_file ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/generators/notify_with/notification/notification_generator.rb', line 26 def create_notification_json_template_file create_file "app/views/api/notifications/_#{file_name}.json.jbuilder", "json.title notification.notification_type\njson.description 'a notification description'\njson.url 'a url for redirect to attached_object'\n FILE\nend\n" |
#create_notification_mail_template_file ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/generators/notify_with/notification/notification_generator.rb', line 10 def create_notification_mail_template_file create_file "app/views/notifications_mailer/#{file_name}.html.erb", "<%# this is a mail template of notifcation \#{file_name} %>\n<p><%= @recipient.name %></p>\n<p><%= @attached_object.body %></p>\n FILE\nend\n" |