File: delivery_method_generator.rb

package info (click to toggle)
ruby-noticed 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: ruby: 1,186; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 985 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require "rails/generators/named_base"

module Noticed
  module Generators
    class DeliveryMethodGenerator < Rails::Generators::NamedBase
      include Rails::Generators::ResourceHelpers

      source_root File.expand_path("../templates", __FILE__)

      desc "Generates a class for a custom delivery method with the given NAME."

      class_option :bulk, desc: "Generate as a bulk delivery method", type: :boolean, default: false

      def generate_notification
        if options[:bulk]
          template "application_bulk_delivery_method.rb", "app/notifiers/application_bulk_delivery_method.rb"
          template "bulk_delivery_method.rb", "app/notifiers/bulk_delivery_methods/#{singular_name}.rb"
        else
          template "application_delivery_method.rb", "app/notifiers/application_delivery_method.rb"
          template "delivery_method.rb", "app/notifiers/delivery_methods/#{singular_name}.rb"
        end
      end
    end
  end
end