Class: SpecialFeedManager

Inherits:
Object
  • Object
show all
Defined in:
lib/special_feed_manager.rb

Overview

Class to handle feeds that need special handling. The handling for each particular special feed is delegated to a specific class that implements the particular handling.

Constant Summary collapse

FETCHER =

Constants for the diferent types of classes needed for special feeds

:fetcher
HANDLER =
:handler

Class Method Summary collapse

Class Method Details

.get_special_fetcher(url) ⇒ Object

Check configuration to see if the URL needs special fetching. In this case, return the fetcher class; this class implements the fetch_feed method, that does whatever is necessary to fetch the URL and returns the response.

If the URL does not need special handling, returns nil.

Receives as argument the URL to check.


41
42
43
44
45
46
47
48
# File 'lib/special_feed_manager.rb', line 41

def self.get_special_fetcher(url)
  fetcher = class_for_url url, FETCHER
  if fetcher.present?
    return fetcher
  end

  return nil
end

.get_special_handler(entry) ⇒ Object

Check configuration to see if the entry belongs to a feed that needs special handling. In this case, return the handler class; this class implements the handle_entry method, that may change the entry or even prevent it from being saved.

If the entry does not belong to a feed that needs special handling, returns nil. If the feed associated with the entry is not present, returns nil.

Receives as argument the entry to check.


22
23
24
25
26
27
28
29
30
31
# File 'lib/special_feed_manager.rb', line 22

def self.get_special_handler(entry)
  if entry.feed.present?
    handler = class_for_url entry.feed.url, HANDLER
    if handler.present?
      return handler
    end
  end

  return nil
end