Sha256: 661e3f57a0ae4e9ab8833bf8fa93e4473c9a7f77ea28225b9d96ff63285f4fa6

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module DeviseOtpAuthenticatable
  class Engine < ::Rails::Engine

    # We use to_prepare instead of after_initialize here because Devise is a Rails engine;
    config.to_prepare do
      DeviseOtpAuthenticatable::Hooks.apply
    end

    initializer "devise-otp", group: :all do |app|
      ActiveSupport.on_load(:devise_controller) do
        include DeviseOtpAuthenticatable::Controllers::UrlHelpers
        include DeviseOtpAuthenticatable::Controllers::Helpers
      end

      ActiveSupport.on_load(:action_view) do
        include DeviseOtpAuthenticatable::Controllers::UrlHelpers
        include DeviseOtpAuthenticatable::Controllers::Helpers
      end

      # See: https://guides.rubyonrails.org/engines.html#separate-assets-and-precompiling
      # check if Rails api mode
      if app.config.respond_to?(:assets)
        if defined?(Sprockets) && Sprockets::VERSION >= "4"
          app.config.assets.precompile << "devise-otp.js"
        else
          # use a proc instead of a string
          app.config.assets.precompile << proc { |path| path == "devise-otp.js" }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise-otp-0.4.0 lib/devise_otp_authenticatable/engine.rb
devise-otp-0.3.0 lib/devise_otp_authenticatable/engine.rb