File: write.rb

package info (click to toggle)
ruby-activeldap 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,588 kB
  • sloc: ruby: 18,143; sh: 12; makefile: 5
file content (38 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module ActiveLdap
  module AttributeMethods
    module Write
      extend ActiveSupport::Concern

      included do
        attribute_method_suffix '='
      end

      private
      def attribute=(attr, *args)
        return set_attribute(attr, args.first)
      end

      # set_attribute
      #
      # Set the value of the attribute called by method_missing?
      def set_attribute(name, value)
        real_name = to_real_attribute_name(name)
        _dn_attribute = nil
        valid_dn_attribute = true
        begin
          _dn_attribute = dn_attribute
        rescue DistinguishedNameInvalid
          valid_dn_attribute = false
        end
        if valid_dn_attribute and real_name == _dn_attribute
          real_name, value = register_new_dn_attribute(real_name, value)
        end
        raise UnknownAttribute.new(name) if real_name.nil?

        @data[real_name] = value
        @simplified_data = nil
      end

    end
  end
end