-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending Mojo::Feed #13
Comments
Hah! That was a issue on my todo list i also wanted to bring up... I like the indirection with the injectible class and i would definitely add that to make subclassing and composing easier. There will always be cases of code that you can't include and we should make that as easy for users as possible. But said that, why not just add |
There are two points here: The one I'm looking at here is how to make Mojo::Feed and Mojo::Feed::Item extensible. The second point (the one you're making) is what are worthwhile additions to Regarding extensibility, I made a quick POC in the extend branch with pluggable classes, and I'm not sure I like that approach - it feels over-engineered rather than elegant. In Israel they say "setup for an air conditioner", because the code looks like a wall with a bricked-up hole in it (I think the more common phrase is YAGNI). A better(?) approach might be to use |
Yeah, you're probably right. Maybe we just just with_roles, see how often we need to extend |
Mojo::Feed
andMojo::Feed::Item
both expose adom
object, so it should be simple to extract more specialized fields from these objects. It would be nice to allow a simple extension mechanism for this.Both
Mojo::Feed
andMojo::Feed::Item
derive fromMojo::Base
, so we can use roles to extend their functionality. I added a simple role example, with a method that returns the type of a feed:https://github.com/dotandimet/Mojo-Feed/blob/master/examples/extending.pl
However, there are complications. To extend
Mojo::Feed::item
, you need to overrideitems
inMojo::Feed
; to smoothly extendMojo::Feed
, you need to modify the internals ofMojo::Feed::Reader
.Or we could make all these classes injectable (ie,
Mojo::Feed
has item_class => 'Mojo::Feed::Item';
, etc)The text was updated successfully, but these errors were encountered: