Sha256: 3246c27c93be619f6a956b6236e7f25cc486d2d759020d8345738673fd49790f

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module LdapQuery
  # Inject the specified helpers into the rails application helpers and controllers for ease of use
  class Railtie < Rails::Railtie
    initializer 'ldap.configure_rails_initialization' do |app|
      app.config.to_prepare do
        # Allow the LDAP gem to be acessible by default from helpers, controllers, and models

        # Add the LdapQuery helpers to the rails applications controllers
        if defined?(ApplicationController)
          ApplicationController.include(LdapQuery::LdapHelper)
        elsif defined?(ActionController::Base)
          ActionController::Base.include(LdapQuery::LdapHelper)
        end
        # Add the LdapQuery helpers to the rails applications helpers
        ApplicationHelper.include(LdapQuery::LdapHelper) if defined?(ApplicationHelper)

        # Allow the LdapQuery helpers to be used in ActiveRecord/Models
        if defined?(ApplicationRecord)
          ApplicationRecord.include(LdapQuery::LdapHelper)
        elsif defined?(ActiveRecord::Base)
          ActiveRecord::Base.include(LdapQuery::LdapHelper)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ldap_query-0.0.1 lib/ldap_query/railtie.rb