Sha256: f1b9a981d42bbeec6e5fc5b25b47f331e356d7d05a74989dd2d0270fa0d325dc

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

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

class TypeGenerator < Rails::Generators::Base

    include Rails::Generators::Migration

    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: NotificationHandler.configuration.default_type, aliases: '-t'

    def create_templates
        template '_default.html.erb', "app/views/notifications/#{options[:type]}/_default.html.erb"
        template '_action_cable.html.erb', "app/views/notifications/#{options[:type]}/_action_cable.html.erb" if defined?(NotificationPusher::ActionCable)
        template '_email.html.erb', "app/views/notifications/#{options[:type]}/_email.html.erb" if defined?(NotificationPusher::Email)
        template '_one_signal.html.erb', "app/views/notifications/#{options[:type]}/_one_signal.html.erb" if defined?(NotificationPusher::OneSignal)
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notification-handler-1.0.0.beta1 generators/type_generator.rb