AC/DC - h3o(software)

For Those About To Rock

This is a little XML-to-object-to-XML library that gets Dirty Deeds Done Dirt Cheap.

Features

  • Take XML string objects and convert them to real Ruby objects from your library

  • Take real Ruby objects and convert them to XML strings

  • Declare XML elements/attributes easily and with type enforcement

Usage

It’s A Long Way To The Top, If You Want To Rock n Roll

AcDc::Body assists you with declaring XML objects with ease. And #acdc makes marshaling those objects from XML a breeze.

require 'acdc'
class TheJack < AcDc::Body
  attribute :shes_got, String
  element :big_balls, String
end

jack = acdc("<thejack shes_got='big-balls'><big_balls>I've got big balls</big_balls></thejack>")
puts jack.shes_got
=> "big_balls"
puts jack.big_balls
=> "I've got big balls"
puts jack.acdc
=> "<?xml version='1.0' encoding='UTF-8'?><thejack shes_got='big-balls'><big_balls>I've got big balls</big_balls></thejack>"

Contact

Special Thanks

I want to thank John Nunemaker for his HappyMapper gem. I stole quite a bit of code from that gem. railstips.org/2008/11/17/happymapper-making-xml-fun-again github.com/jnunemaker/happymapper/

And if you might ask why not just use his library? Well - that’s the acdc part of this story. He had the AC - I added the DC.