Sha256: 0e791877f1239073790333e0b80040e0f270b00b0081287064373280378e46a7

Contents?: true

Size: 954 Bytes

Versions: 5

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.exists?(path) &&
          !File.read(path).include?("authy_authenticatable")
          inject_into_file(path,
                           "authy_authenticatable, :",
                           :after => "devise :")
        end

        if File.exists?(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

5 entries across 5 versions & 1 rubygems

Version Path
devise-authy-2.3.0 lib/generators/devise_authy/devise_authy_generator.rb
devise-authy-2.2.1 lib/generators/devise_authy/devise_authy_generator.rb
devise-authy-2.2.0 lib/generators/devise_authy/devise_authy_generator.rb
devise-authy-2.1.0 lib/generators/devise_authy/devise_authy_generator.rb
devise-authy-2.0.0 lib/generators/devise_authy/devise_authy_generator.rb