Sha256: c3beeb97fc28c991530b822f6c839fa77c409b4cb357940899eaaceff8206f7f

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module SwitchUser
  if defined? Rails::Engine
    class Engine < Rails::Engine
      config.to_prepare do
        ApplicationController.helper(SwitchUserHelper)
      end
    end
  else
    %w(controllers helpers).each do |dir|
      path = File.join(File.dirname(__FILE__), '..', 'app', dir)
      $LOAD_PATH << path
      ActiveSupport::Dependencies.load_paths << path
      ActiveSupport::Dependencies.load_once_paths.delete(path)
      ActionView::Base.send :include, SwitchUserHelper
    end
  end

  mattr_accessor :provider
  self.provider = :devise

  mattr_accessor :available_users
  self.available_users = { :user => lambda { User.all } }

  mattr_accessor :display_field
  self.display_field = :email

  mattr_accessor :controller_guard
  self.controller_guard = lambda { |current_user, request| Rails.env == "development" }
  mattr_accessor :view_guard
  self.view_guard = lambda { |current_user, request| Rails.env == "development" }

  mattr_accessor :redirect_path
  self.redirect_path = lambda { |request, params| request.env["HTTP_REFERER"] ? :back : root_path }

  def self.setup
    yield self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
switch_user-0.5.1 lib/switch_user.rb