Class: Pushing::NotifierGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/pushing/notifier_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_notifier_fileObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/pushing/notifier_generator.rb', line 9

def create_notifier_file
  template "notifier.rb", File.join("app/notifiers", class_path, "#{file_name}_notifier.rb")

  actions.each do |action|
    template "template.json+apn.jbuilder", File.join("app/views/", "#{file_name}_notifier", "#{action}.json+apn.jbuilder")
    template "template.json+fcm.jbuilder", File.join("app/views/", "#{file_name}_notifier", "#{action}.json+fcm.jbuilder")
  end

  in_root do
    if behavior == :invoke && !File.exist?(application_notifier_file_name)
      template "application_notifier.rb", application_notifier_file_name
    end

    if behavior == :invoke && !File.exist?(initializer_file_name)
      template "initializer.rb", initializer_file_name
    end
  end
end