# module ActiveLdap::AttributeMethods::Read

### Protected Instance Methods

attribute(attr, *args) click to toggle source

    # File lib/active_ldap/attribute_methods/read.rb, line 7
    def attribute(attr, *args)
      return get_attribute(attr, args.first)
    end

get_attribute(name, force_array=false) click to toggle source

#get_attribute

Return the value of the attribute called by method_missing?

    # File lib/active_ldap/attribute_methods/read.rb, line 14
    def get_attribute(name, force_array=false)
      name, value = get_attribute_before_type_cast(name, force_array)
      return value if name.nil?
      attribute = schema.attribute(name)
      type_cast(attribute, value)
    end

type_cast(attribute, value) click to toggle source

    # File lib/active_ldap/attribute_methods/read.rb, line 21
    def type_cast(attribute, value)
      case value
      when Hash
        result = {}
        value.each do |option, val|
          result[option] = type_cast(attribute, val)
        end
        if result.size == 1 and result.has_key?("binary")
          result["binary"]
        else
          result
        end
      when Array
        value.collect do |val|
          type_cast(attribute, val)
        end
      else
        attribute.type_cast(value)
      end
    end