Sha256: 6583a788563117d3959994d653fd8b44211f7ffba89a34d4cfe6b0dd869f73fe

Contents?: true

Size: 1.06 KB

Versions: 14

Compression:

Stored size: 1.06 KB

Contents

module ActiveLdap
  module AttributeMethods
    module Read
      extend ActiveSupport::Concern

    protected
      def attribute(attr, *args)
        return get_attribute(attr, args.first)
      end

      # get_attribute
      #
      # Return the value of the attribute called by method_missing?
      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

      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

    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
activeldap-5.1.1 lib/active_ldap/attribute_methods/read.rb
activeldap-5.1.0 lib/active_ldap/attribute_methods/read.rb
activeldap-3.2.3 lib/active_ldap/attribute_methods/read.rb
powerhome-activeldap-3.2.3 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.6 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.5 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.4 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.3 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.2 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.1 lib/active_ldap/attribute_methods/read.rb
activeldap-4.0.0 lib/active_ldap/attribute_methods/read.rb
activeldap-3.2.2 lib/active_ldap/attribute_methods/read.rb
activeldap-3.2.1 lib/active_ldap/attribute_methods/read.rb
activeldap-3.2.0 lib/active_ldap/attribute_methods/read.rb