Sha256: c19baf62f6a084decb99cee277e92d5de8113c5c0595a6531b1d0b9647ecbf28

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require "rails/generators"

module Ahoy
  module Generators
    class MessagesGenerator < Rails::Generators::Base
      source_root File.join(__dir__, "templates")

      class_option :unencrypted, type: :boolean

      def copy_templates
        activerecord = defined?(ActiveRecord)
        mongoid = defined?(Mongoid)

        selection =
          if activerecord && mongoid
            puts <<-MSG

Which data store would you like to use?
 1. Active Record (default)
 2. Mongoid
            MSG

            ask(">")
          elsif activerecord
            "1"
          else
            "2"
          end

        case selection
        when "", "1"
          invoke "ahoy:messages:activerecord"
        when "2"
          invoke "ahoy:messages:mongoid"
        else
          abort "Error: must enter a number [1-2]"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahoy_email-2.0.0 lib/generators/ahoy/messages_generator.rb