| Module | ActiveLdap::Attributes::ClassMethods |
| In: |
lib/active_ldap/attributes.rb
|
# File lib/active_ldap/attributes.rb, line 12
12: def attr_protected(*attributes)
13: targets = attributes.collect {|attr| attr.to_s} - protected_attributes
14: instance_variable_set("@attr_protected", targets)
15: end
# File lib/active_ldap/attributes.rb, line 23
23: def blank_value?(value)
24: case value
25: when Hash
26: value.values.all? {|val| blank_value?(val)}
27: when Array
28: value.all? {|val| blank_value?(val)}
29: when String
30: /\A\s*\z/ =~ value
31: when nil
32: true
33: else
34: value.blank?
35: end
36: end
# File lib/active_ldap/attributes.rb, line 17
17: def protected_attributes
18: ancestors[0..(ancestors.index(Base))].inject([]) do |result, ancestor|
19: result + ancestor.instance_eval {@attr_protected ||= []}
20: end
21: end
# File lib/active_ldap/attributes.rb, line 38
38: def remove_blank_value(value)
39: case value
40: when Hash
41: result = {}
42: value.each do |k, v|
43: result[k] = remove_blank_value(v) || []
44: end
45: result
46: when Array
47: result = []
48: value.each do |v|
49: v = remove_blank_value(v)
50: next if v.nil?
51: result << v
52: end
53: result
54: when String
55: if /\A\s*\z/ =~ value
56: nil
57: else
58: value
59: end
60: else
61: value
62: end
63: end