| 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: v = remove_blank_value(v)
44: next if v.nil?
45: result[k] = v
46: end
47: result = nil if result.blank?
48: result
49: when Array
50: result = []
51: value.each do |v|
52: v = remove_blank_value(v)
53: next if v.nil?
54: result << v
55: end
56: result = nil if result.blank?
57: result
58: when String
59: if /\A\s*\z/ =~ value
60: nil
61: else
62: value
63: end
64: else
65: value
66: end
67: end