Sha256: f910402ade0298c5fa1fc7fa9367cb040d3f4a974b51bacb61cc3b04df8d2842

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 Bytes

Contents

# To be included in models

module DeviseLDAPMultiple

  extend ActiveSupport::Concern

  # Lets you specify a list off attributes to return, and returns them in a hash
  # If not attributes are specified, all attributes are returned in a hash
  # (with the exception of some fields which clog up the console since they're huge)
  def ldap (*options)
    attributes = {}
    unless options.empty?
      options.each do |option|
        attributes[option] = Devise::LDAP::Adapter.get_ldap_param(self.email, option, self.current_scope).first
      end
    else
      attributes = Devise::LDAP::Adapter.get_ldap_entry(self.email, self.current_scope).myhash.except(:usercertificate).except :thumbnailphoto, :usercertificate, :homemdb, :msexchsafesendershash
    end
    attributes
  end

  # Returns the name of the model from the object calling this function
  def current_scope
    self.class.name.downcase.split("::").last.to_s
  end

  # Placeholder for future class methods
  module ClassMethods
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_ldap_multiple-0.9.2 lib/devise_ldap_multiple/concern.rb