Class: CacheReporter

Inherits:
MotiroReporter show all
Defined in:
app/core/cache_reporter.rb

Overview

A cache reporter is a reporter that just repeats news discovered by real reporters

Every cache reporter has a real reporter that it tries to mimic. This type of reporter will go to the news database and retrieve all news that its real correspondent reported.

Instance Method Summary collapse

Methods inherited from MotiroReporter

add, button, #buttons, #cache?, caching, #latest_headline, reporter_name, title

Constructor Details

#initialize(reporter, settings = SettingsProvider.new, headlines_source = Headline) ⇒ CacheReporter

Returns a new instance of CacheReporter.



28
29
30
31
32
33
# File 'app/core/cache_reporter.rb', line 28

def initialize(reporter, settings=SettingsProvider.new,
               headlines_source=Headline)
  @headlines_source = headlines_source
  @settings = settings
  @source_reporter = reporter
end

Instance Method Details

#channel_titleObject



49
# File 'app/core/cache_reporter.rb', line 49

def channel_title; @source_reporter.channel_title; end

#headline(rid) ⇒ Object



44
45
46
# File 'app/core/cache_reporter.rb', line 44

def headline(rid)
  @headlines_source.find_with_reporter_and_rid(name, rid)
end

#headlinesObject



39
40
41
42
# File 'app/core/cache_reporter.rb', line 39

def headlines
  @headlines_source.find(:all, :conditions => ['reported_by = ?', name],
                               :order => 'happened_at DESC')
end

#latest_headlinesObject



35
36
37
# File 'app/core/cache_reporter.rb', line 35

def latest_headlines
  @headlines_source.latest(@settings.package_size, name)
end

#nameObject



48
# File 'app/core/cache_reporter.rb', line 48

def name; @source_reporter.name; end

#params_for(rid) ⇒ Object



50
# File 'app/core/cache_reporter.rb', line 50

def params_for(rid); @source_reporter.params_for(rid); end