Extending Feedzirra

65 views
Skip to first unread message

Matthew Gowie

unread,
Feb 23, 2012, 4:13:16 PM2/23/12
to feedzirra
I am trying to extend the Feed class so I can call entry.identifier
and get the title of the entry. I am doing this so I can have an
abstract partial for a bunch of objs.

have gotten stuck however as I am not understanding exactly what and
where I should put code.

From reading the section on extending in the Feedzirra readme, I think
I should be using something like :

Feedzirra::Feed.add_common_feed_entry_element('geo:lat', :as => :lat),
but my version is

Feedzirra::Feed.add_common_feed_entry_element('title', :as
=> :identifier)
and another that does the same thing pretty much:
Feedzirra::Feed.add_common_feed_entry_element('title', :as => :name)

I tried putting these right above where I call fetch_and_parse and
also in my environments.rb file, but neither worked. So I am wondering
what I am doing wrong. I don't know much about extending gems in
general so it is probably something trivial that I am overlooking.

Any help is appreciated.

Paul Dix

unread,
Mar 3, 2012, 11:48:34 AM3/3/12
to feed...@googlegroups.com
Hey Matthew,
There's already an accessor for title so you can't add it like that.
If you really just want a method called 'identifier' that returns the
title (which is already being parsed) then you could do it like this:

Feed.feed_classes.each do |class|
class.send(:define_method, :identifier) { title }
end

Hope that helps,
Paul

> --
> You received this message because you are subscribed to the Google Groups "feedzirra" group.
> To post to this group, send email to feed...@googlegroups.com.
> To unsubscribe from this group, send email to feedzirra+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/feedzirra?hl=en.
>

Reply all
Reply to author
Forward
0 new messages