Sha256: 89ac98c394f7f9ff1122929767ca7d249ca7a7b1a152ee8b703e40aa4d3ed0d6

Contents?: true

Size: 1.94 KB

Versions: 7

Compression:

Stored size: 1.94 KB

Contents

module PushType
  module Auth
    class Engine < ::Rails::Engine
      isolate_namespace PushType
      engine_name 'push_type_auth'

      config.generators do |g|
        g.assets false
        g.helper false
        g.test_framework  :test_unit, fixture: false
      end

      initializer 'push_type_auth.reloader' do |app|
        reload_block = -> {
          # Make User authenticatable
          PushType::User.include PushType::Authenticatable
          
          # Extend controllers with auth/invitation methos
          PushType::AdminController.include PushType::AuthenticationMethods
          PushType::UsersController.include PushType::InvitationMethods
          
          # Configure devise with helpers and layout
          DeviseController.helper PushType::AdminHelper
          Devise::Mailer.layout 'push_type/email'

          # Reload routes
          app.reload_routes!
        }

        # Use ActiveSupport::Reloader if available in Rails 5
        # Fall back to ActionDispatch::Reloader for earlier Rails
        if defined? ActiveSupport::Reloader
          app.reloader.to_prepare &reload_block
        else
          ActionDispatch::Reloader.to_prepare &reload_block
        end
      end

      initializer 'push_type_auth.devise_config' do
        Devise.mailer_sender = PushType.config.mailer_sender
        Devise.router_name = :push_type
      end

      initializer 'push_type.auth_assets' do
        ActiveSupport.on_load :push_type_admin do
          admin_assets.javascripts << 'push_type/auth'
        end
      end

      initializer 'push_type_auth.menus' do
        PushType.menu :utility do
          item :settings do
            text  { ficon(:widget) }
            link  { push_type.edit_profile_path }
          end
          item :sign_out do
            text  { ficon(:power) }
            link  { push_type.destroy_user_session_path }
            link_options method: 'delete'
          end
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
push_type_auth-0.9.5 lib/push_type/auth/engine.rb
push_type_auth-0.9.3 lib/push_type/auth/engine.rb
push_type_auth-0.9.2 lib/push_type/auth/engine.rb
push_type_auth-0.9.1 lib/push_type/auth/engine.rb
push_type_auth-0.9.0 lib/push_type/auth/engine.rb
push_type_auth-0.9.0.beta.4 lib/push_type/auth/engine.rb
push_type_auth-0.9.0.beta.3 lib/push_type/auth/engine.rb