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.



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

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

Instance Method Details

#channel_titleObject



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

def channel_title; @source_reporter.channel_title; end

#headline(rid) ⇒ Object



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

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

#headlinesObject



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

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

#latest_headlinesObject



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

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

#nameObject



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

def name; @source_reporter.name; end

#params_for(rid) ⇒ Object



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

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