avoid "warning: Hash#index is deprecated; use Hash#key" with ruby 1.9
authorGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 3 Sep 2010 07:18:02 +0000 (09:18 +0200)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 3 Sep 2010 07:18:02 +0000 (09:18 +0200)
lib/booh/rexml/element.rb

index 2676fcff4efac990b426b84bd7a99fdf09da5c3b..fbc5d0c40ac997933ff775b2b202b655872a96a8 100644 (file)
@@ -551,9 +551,13 @@ module REXML
                #################################################
 
                def attribute( name, namespace=nil )
-                       prefix = nil
-      prefix = namespaces.index(namespace) if namespace
-                       attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
+                    prefix = nil
+                    if namespaces.respond_to? :key
+                        prefix = namespaces.key(namespace) if namespace
+                    else
+                        prefix = namespaces.index(namespace) if namespace
+                    end
+                    attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
                end
 
                # Evaluates to +true+ if this element has any attributes set, false