As I sat around last night refactoring the View::Feed/View::Feed::(Atom|RSS) code in Mango because critic told me process() was too complex (and it was), a little voice popped into my head and told me I should just release it as a new dist. Most of this is code from helpful others who have embarked down the same path.

It's been mentioned a few times, and there are some variations on the code. In a nutshell, it supports creating a feed from:

## just hashed data
{
  xml_feed_attribute => 'value',
  xml_feed_attribute => 'value',
  xml_feed_attribute => 'value',
  entries => [
    xml_feed_item_attribute => 'value',
    xml_feed_item_attribute => 'value',
    xml_feed_item_attribute => 'value',
  ],
}

## objects with as_feed returning XML::Feed
$someobj->as_feed;

## objects with as_feed returning a hash
$someobj->as_feed( return {
  xml_feed_attribute => 'value',
  xml_feed_attribute => 'value',
  xml_feed_attribute => 'value',
  entries => [
    xml_feed_item_attribute => 'value',
    xml_feed_item_attribute => 'value',
    xml_feed_item_attribute => 'value',
  ],
})

The entries key can also be an array of XML::Feed::Item objects, an array of objects that return hashes or XML::Feed::Item from as_feed_item
methods.

View::Feed::Atom and View::Feed::RSS simply use View::Feed and set the appropriate content-type.

Nothing fancy, but enough code to share an not have to rewrite again somewhere else.

If anyone thinks it's worth the effort, I'll kick out a dist this weekend.

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to