Skip to content
This repository
Browse code

Added missing to_xml_attributes method to hash

  • Loading branch information...
commit 6f361ed59e11ca29e4967c876567be7cf8e9cca7 1 parent a0f8ade
John Nunemaker authored December 08, 2008
4  History
... ...
@@ -1,3 +1,7 @@
  1
+== 0.2.2 2008-12-08
  2
+* 1 bug fix
  3
+  * Added the missing core extension hash method to_xml_attributes
  4
+
1 5
 == 0.2.1 2008-12-08
2 6
 * 1 bug fix
3 7
   * Fixed that HTTParty was borking ActiveSupport and as such Rails (thanks to Rob Sanheim)
11  lib/core_extensions.rb
@@ -333,4 +333,15 @@ def normalize_param(key, value)
333 333
 
334 334
     param
335 335
   end
  336
+  
  337
+  # @return <String> The hash as attributes for an XML tag.
  338
+  #
  339
+  # @example
  340
+  #   { :one => 1, "two"=>"TWO" }.to_xml_attributes
  341
+  #     #=> 'one="1" two="TWO"'
  342
+  def to_xml_attributes
  343
+    map do |k,v|
  344
+      %{#{k.to_s.snake_case.sub(/^(.{1,1})/) { |m| m.downcase }}="#{v}"}
  345
+    end.join(' ')
  346
+  end
336 347
 end
2  lib/httparty/version.rb
... ...
@@ -1,3 +1,3 @@
1 1
 module HTTParty
2  
-  Version = '0.2.1'
  2
+  Version = '0.2.2'
3 3
 end

1 note on commit 6f361ed

Kenneth Kalmer

Thanks John, this fixed the issue reported in this gist: http://gist.github.com/33647

Please sign in to comment.
Something went wrong with that request. Please try again.