public Method

Hash.to_xml_attributes

Converts the hash into xml attributes

{ :one => "ONE", "two"=>"TWO" }.to_xml_attributes
#=> 'one="ONE" two="TWO"'

Source Code

# File merb/core_ext/hash.rb, line 135
def to_xml_attributes
  map do |k,v|
    %{#{k.to_s.camelize.sub(/^(.{1,1})/) { |m| m.downcase }}="#{v}"} 
  end.join(' ')
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.