in reply to Re: Moose? Add a new attribute to a XML::Feed::Content object?
in thread Moose? Add a new attribute to a XML::Feed::Content object?
I added in the monkey patch. However I am not getting the results I am expecting when I dosub get_by_id { my ($self, $feed_id) = @_; my $feed = $self->single({id => $feed_id}); sub XML::Feed::Content::body_alt { shift->_var('body_alt', @_) }; my $xml_feed = XML::Feed->parse(URI->new($feed->url)); $xml_feed->{'url'} = $feed->url; use WWW::Translate::Apertium; foreach ($xml_feed->entries) { my $engine = WWW::Translate::Apertium->new(lang_pair => 'en-ca'); my $translated_string = $engine->translate($_->content->body); #This change $_->content->body_alt $_->content->body_alt($translated_string); } return $xml_feed; }
Which shows us[% FOREACH entry IN feed.entries %] [% USE Dumper %] [% Dumper.dump(entry.content) %] [% END %]
I see there is no body_alt. Now what am I doing wrong?$VAR1 = bless( { 'body' => 'This is a test post', 'base' => undef, 'ty +pe' => 'text/html' }, 'XML::Feed::Content' );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Moose? Add a new attribute to a XML::Feed::Content object?
by Corion (Patriarch) on Mar 28, 2011 at 19:27 UTC |
In Section
Seekers of Perl Wisdom