Monday, February 18, 2008

Sexy Resource: ActiveResource .xml Stripper

Following on the heels of Dapper Resource, Snazzy Resource, and Spiffy Resource, Sexy Resource is yet another ActiveResource plugin by Giles Bowkett.

script/plugin \
install http://sexy-resource.googlecode.com/svn/trunk/active_resource_xml_stripper/


Sexy Resource is useful for when you're using ActiveResource against non-Rails-y, non-XML-y Web services. You pass in a :dot_xml => false, and a regex steals away the .xml usually appended to ARes URLs.

For instance, we needed to authenticate user credentials against a CMS called Alfresco:



The self.foo methods allow you to take your URL outside the boundaries of Rails' convention over configuration assumptions, but there's one more step to take, and the :dot_xml => false takes it.

(It's not actually that sexy, but after the first three plugins, someone said I should name the next one Sexy Resource. The next one turned out to involve a stripper, sort of, so it seemed like the right time.)