Sha256: 6049ba85f91c5b7ac3be1b4f6e9ae343d106a8fec2b0b82aa10c34adc79c91f8

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

module DeviseAuthy
  module Generators
    class DeviseAuthyGenerator < Rails::Generators::NamedBase
      namespace "devise_authy"

      desc "Add :authy_authenticatable directive in the given model, plus accessors. Also generate migration for ActiveRecord"

      def inject_devise_authy_content
        path = File.join(destination_root, "app", "models", "#{file_path}.rb")
        if File.exist?(path) &&
           !File.read(path).include?("authy_authenticatable")
          inject_into_file(path,
                           "authy_authenticatable, :",
                           :after => "devise :")
        end

        if File.exist?(path) &&
           !File.read(path).include?(":authy_id")
          inject_into_file(path,
                           ":authy_id, :last_sign_in_with_authy, ",
                           :after => "attr_accessible ")
        end
      end

      hook_for :orm
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-authy-2.3.1 lib/generators/devise_authy/devise_authy_generator.rb