Sha256: f42bd9982a3366f81f0293d428f5cccb69f3ef897ec0b5d59fa959a6584ceb26

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

require 'sorcery'
require 'rails'

module Sorcery
  # The Sorcery engine takes care of extending ActiveRecord (if used) and ActionController,
  # With the plugin logic.
  class Engine < Rails::Engine
    config.sorcery = ::Sorcery::Controller::Config

    # TODO: Should this include a modified version of the helper methods?
    initializer 'extend Controller with sorcery' do
      # FIXME: on_load is needed to fix Rails 6 deprecations, but it breaks
      #        applications due to undefined method errors.
      # ActiveSupport.on_load(:action_controller_api) do
      if defined?(ActionController::API)
        ActionController::API.send(:include, Sorcery::Controller)
      end

      # FIXME: on_load is needed to fix Rails 6 deprecations, but it breaks
      #        applications due to undefined method errors.
      # ActiveSupport.on_load(:action_controller_base) do
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, Sorcery::Controller)
        ActionController::Base.helper_method :current_user
        ActionController::Base.helper_method :logged_in?
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sorcery-0.17.0 lib/sorcery/engine.rb
sorcery-0.16.5 lib/sorcery/engine.rb
sorcery-0.16.4 lib/sorcery/engine.rb
sorcery-0.16.3 lib/sorcery/engine.rb
sorcery-0.16.2 lib/sorcery/engine.rb
sorcery-0.16.1 lib/sorcery/engine.rb
sorcery-0.15.1 lib/sorcery/engine.rb
sorcery-0.16.0 lib/sorcery/engine.rb
sorcery-0.15.0 lib/sorcery/engine.rb