Sha256: 213a258120f67a0fab62c4874a2cf3d501c9ff5bbc446555b72b8620647f46ee

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

module UcbRails
  module Configuration
    
    class Ldap
      attr_accessor :config
      
      def initialize(config)
        self.config = config.presence || {}
      end
      
      def configure
        configure_host
        authenticate
      end
      
      private

      def configure_host
        UCB::LDAP.host = config.fetch('host', default_host)
      end

      def authenticate
        if config.has_key?('username')
          UCB::LDAP.authenticate config['username'], config['password']
        end
      end

      def default_host
        RailsEnvironment.production? ? 'nds.berkeley.edu' : 'nds-test.berkeley.edu'
      end

      class << self
        def configure(config)
          new(config).configure
        end
      end
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ucb_rails-0.0.8 app/models/ucb_rails/configuration/ldap.rb
ucb_rails-0.0.7 app/models/ucb_rails/configuration/ldap.rb