Sha256: bd0b12cd3953503684086d7a6fe86db5d54cd1e09ba3e95cb0c398d10a0950bc

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require "rails/generators"

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

        class_option :encryption, type: :string
        # deprecated
        class_option :unencrypted, type: :boolean

        def copy_templates
          case encryption
          when "lockbox"
            template "mongoid_lockbox.rb", "app/models/ahoy/message.rb"
          else
            template "mongoid.rb", "app/models/ahoy/message.rb"
          end
        end

        # TODO remove default
        def encryption
          case options[:encryption]
          when "lockbox", "none"
            options[:encryption]
          when nil
            if options[:unencrypted]
              # TODO deprecation warning
              "none"
            else
              "lockbox"
            end
          else
            abort "Error: encryption must be lockbox or none"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ahoy_email-2.1.2 lib/generators/ahoy/messages/mongoid_generator.rb
ahoy_email-2.1.1 lib/generators/ahoy/messages/mongoid_generator.rb