Sha256: ade50fbb827e137823f1b4a522a59a72bff20dd5925de0296e384416172a3cc3

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module DeviseLdapMultiple

  class InstallGenerator < Rails::Generators::Base

    source_root File.expand_path("../templates", __FILE__)

    # ToDo: Request user input to use a scope that already exists, or make it a parameter to pass into the generator
    def create_ldap_config
      copy_file "default.yml", "config/ldap/default.yml"
    end

    def create_default_devise_settings
      inject_into_file "config/initializers/devise.rb", default_devise_settings, :after => "Devise.setup do |config|\n"
    end

    def update_application_controller
      inject_into_class "app/controllers/application_controller.rb", ApplicationController, rescue_from_exception if options.add_rescue?
    end

    private

    def default_devise_settings
      settings = <<-eof
  # ==> Devise LDAP Multiple configuration
  config.ldap_default_scope = 'default'
      eof
      settings
    end

    def rescue_from_exception
      <<-eof
  rescue_from DeviseLdapMultiple::LdapException do |exception|
    render :text => exception, :status => 500
  end
      eof
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_ldap_multiple-0.9.0 lib/generators/devise_ldap_multiple/install_generator.rb