Class: Wupee::NotificationTypeGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Wupee::NotificationTypeGenerator
- Defined in:
- lib/generators/wupee/notification_type/notification_type_generator.rb
Instance Method Summary collapse
- #add_notification_subject ⇒ Object
- #create_notification_html_template_file ⇒ Object
- #create_notification_json_template_file ⇒ Object
- #create_notification_type_object ⇒ Object
Instance Method Details
#add_notification_subject ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/generators/wupee/notification_type/notification_type_generator.rb', line 2 def add_notification_subject inject_into_file "config/locales/#{I18n.locale.to_s}.yml", after: /email_subjects:\n/ do <<-CODE #{file_name}: "#{file_name}" CODE end end |
#create_notification_html_template_file ⇒ Object
18 19 20 21 |
# File 'lib/generators/wupee/notification_type/notification_type_generator.rb', line 18 def create_notification_html_template_file create_file "app/views/wupee/notifications/_#{file_name}.html.erb", <<-FILE FILE end |
#create_notification_json_template_file ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/generators/wupee/notification_type/notification_type_generator.rb', line 10 def create_notification_json_template_file create_file "app/views/wupee/api/notifications/_#{file_name}.json.jbuilder", <<-FILE json.subject "subject" json.body "body" json.url "url" FILE end |
#create_notification_type_object ⇒ Object
23 24 25 |
# File 'lib/generators/wupee/notification_type/notification_type_generator.rb', line 23 def create_notification_type_object Wupee::NotificationType.create!(name: file_name) end |