Sha256: 8c899aebd32e8289fbb7a66edb20feb252da9464591b1c3515e34211be880edf

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'
require 'rails/generators/migration'

module NotificationRenderer
  class TypeGenerator < Rails::Generators::Base
    source_root(File.join(File.dirname(__FILE__), '../templates/type'))
    desc 'Create a new notification type'
    class_option :type,
                 desc: 'Specify the notification type',
                 type: :string,
                 default: NotificationRenderer.configuration.default_type,
                 aliases: '-t'
    class_option :renderers,
                 desc: 'Specify the renderer templates',
                 type: :string,
                 default: NotificationRenderer.configuration.default_renderer,
                 aliases: '-r'

    def create_templates
      options[:renderers].split(' ')&.each do |template|
        template(
          '_template.html',
          "app/views/notifications/#{options[:type]}/_#{template}.html.erb"
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
notification-renderer-3.0.2 lib/generators/notification_renderer/type_generator.rb
notification-renderer-2.0.0 lib/generators/notification_renderer/type_generator.rb
notification-renderer-1.2.6 lib/generators/notification_renderer/type_generator.rb