Sha256: 3ab7b03c5ed757a733aabf8ef597774006369cf5099b1b8b55dd3091c933db89

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

module DeviseOtpAuthenticatable
  class Engine < ::Rails::Engine
    config.devise_otp = ActiveSupport::OrderedOptions.new
    config.devise_otp.precompile_assets = true

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-otp-1.0.0 lib/devise_otp_authenticatable/engine.rb
devise-otp-0.8.0 lib/devise_otp_authenticatable/engine.rb
devise-otp-0.7.1 lib/devise_otp_authenticatable/engine.rb
devise-otp-0.7.0 lib/devise_otp_authenticatable/engine.rb