ldaptic 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -297,7 +297,7 @@ module Ldaptic
297
297
  end
298
298
 
299
299
  def safe_array(attributes)
300
- Array(attributes).flatten.compact.map {|x| format(x)}
300
+ [attributes].flatten.compact.map {|x| format(x)}
301
301
  end
302
302
 
303
303
  def typecast(value)
@@ -7,16 +7,6 @@ module Ldaptic
7
7
  # contructed that mirrors the server's object classes. Ldaptic::Entry
8
8
  # serves as the base class for this hierarchy.
9
9
  class Entry
10
- # Constructs a deep copy of a set of LDAP attributes, normalizing them to
11
- # arrays as appropriate. The returned hash has a default value of [].
12
- def self.clone_ldap_hash(attributes) #:nodoc:
13
- hash = Hash.new
14
- attributes.each do |k, v|
15
- k = k.kind_of?(Symbol) ? k.to_s.tr('_', '-') : k.dup
16
- hash[k] = Array(v).map {|x| x.dup rescue x}
17
- end
18
- hash
19
- end
20
10
 
21
11
  # For Active Model compliance. Delegates to #namespace.
22
12
  def self.model_name
@@ -161,7 +151,7 @@ module Ldaptic
161
151
  logger.warn "#{name}: invalid object class for #{attributes.inspect}"
162
152
  end
163
153
  obj = allocate
164
- obj.instance_variable_set(:@dn, ::Ldaptic::DN(Array(attributes.delete('dn')).first, obj))
154
+ obj.instance_variable_set(:@dn, ::Ldaptic::DN([attributes.delete('dn')].flatten.first, obj))
165
155
  obj.instance_variable_set(:@original_attributes, attributes)
166
156
  obj.instance_variable_set(:@attributes, {})
167
157
  obj.instance_eval { common_initializations; after_load }
@@ -272,7 +262,7 @@ module Ldaptic
272
262
  end
273
263
 
274
264
  def to_s
275
- "#<#{self.class} #{dn}>"
265
+ dn || ''
276
266
  end
277
267
 
278
268
  # Reads an attribute and typecasts it if neccessary. If the argument given
@@ -242,7 +242,7 @@ module Ldaptic
242
242
 
243
243
  def normalize_attributes(attributes)
244
244
  attributes.inject({}) do |h, (k, v)|
245
- h.update(Ldaptic.encode(k) => v.respond_to?(:before_type_cast) ? v.before_type_cast : Array(v))
245
+ h.update(Ldaptic.encode(k) => v.respond_to?(:before_type_cast) ? v.before_type_cast : [v].flatten.compact)
246
246
  end
247
247
  end
248
248
  private :normalize_attributes
@@ -260,7 +260,7 @@ module Ldaptic
260
260
  attributes = normalize_attributes(attributes)
261
261
  else
262
262
  attributes = attributes.map do |(action, key, values)|
263
- [action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : Array(values)]
263
+ [action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact]
264
264
  end
265
265
  end
266
266
  log_dispatch(:modify, dn, attributes)
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldaptic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 1
10
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Tim Pope
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-30 00:00:00 -05:00
17
+ date: 2011-02-05 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 59
30
28
  segments:
31
29
  - 0
32
30
  - 9
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 27
46
43
  segments:
47
44
  - 0
48
45
  - 1
@@ -58,7 +55,6 @@ dependencies:
58
55
  requirements:
59
56
  - - ~>
60
57
  - !ruby/object:Gem::Version
61
- hash: 7
62
58
  segments:
63
59
  - 3
64
60
  - 0
@@ -125,7 +121,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
121
  requirements:
126
122
  - - ">="
127
123
  - !ruby/object:Gem::Version
128
- hash: 3
129
124
  segments:
130
125
  - 0
131
126
  version: "0"
@@ -134,7 +129,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
129
  requirements:
135
130
  - - ">="
136
131
  - !ruby/object:Gem::Version
137
- hash: 3
138
132
  segments:
139
133
  - 0
140
134
  version: "0"