Class: Wupee::NotificationTypeGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/wupee/notification_type/notification_type_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_notification_subjectObject



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
"    \#{file_name}: \"\#{file_name}\"\n"
  end
end

#create_notification_html_template_fileObject



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\nend\n"

#create_notification_json_template_fileObject



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", "json.subject \"subject\"\njson.body \"body\"\njson.url \"url\"\n  FILE\nend\n"

#create_notification_type_objectObject



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