Class: MotiroReporter
- Inherits:
-
Object
- Object
- MotiroReporter
- Defined in:
- app/core/reporter.rb
Overview
A reporter is someone capable of going out for news
For a Motiro reporter, “going out” may include, but is not limited to, accessing the local file system, executing external processes and consulting the web
Direct Known Subclasses
CacheReporter, DarcsReporter, SubversionReporter, WikiReporter
Class Method Summary collapse
-
.add(code) ⇒ Object
Adds a button to this reporter’s toolbar.
-
.button ⇒ Object
A hash of buttons available for reporters.
-
.caching(switch) ⇒ Object
Turns caching on and off for the reporter.
- .reporter_name ⇒ Object
-
.title(title) ⇒ Object
Replaces the default title with a custom one.
Instance Method Summary collapse
- #buttons ⇒ Object
- #cache? ⇒ Boolean
- #channel_title ⇒ Object
- #latest_headline ⇒ Object
- #name ⇒ Object
- #params_for(rid) ⇒ Object
Class Method Details
.add(code) ⇒ Object
Adds a button to this reporter’s toolbar. Accepts a text parameter that will be fed into the ERB templates when generating web pages.
It is a better idea to use one of the buttons available on the buttons hash than to hard-code the button code.
59 60 61 |
# File 'app/core/reporter.rb', line 59 def self.add(code) write_inheritable_array 'buttons', [code] end |
.button ⇒ Object
A hash of buttons available for reporters
Usage : class MyReporter < MotiroReporter
add_button buttons[:older]
end
68 69 70 |
# File 'app/core/reporter.rb', line 68 def self. @@buttons ||= { :older => OLDER_BUTTON } end |
.caching(switch) ⇒ Object
Turns caching on and off for the reporter
Usage : class MyReporter < MotiroReporter
caching :off
end
77 78 79 |
# File 'app/core/reporter.rb', line 77 def self.caching(switch) define_method :cache? do; :off != switch; end end |
.reporter_name ⇒ Object
34 35 36 37 |
# File 'app/core/reporter.rb', line 34 def self.reporter_name class_name = self.name return class_name[0, class_name.size - 8].underscore end |
.title(title) ⇒ Object
Replaces the default title with a custom one. Example usage:
class MyReporter < MotiroReporter
title "This is my reporter's custom title"
end
MyReporter.new.channel_title => "This is my reporter's custom title"
If not called, a default title will be generated based on the class name
48 49 50 51 52 |
# File 'app/core/reporter.rb', line 48 def self.title(title) define_method :channel_title do title.t end end |
Instance Method Details
#buttons ⇒ Object
89 90 91 |
# File 'app/core/reporter.rb', line 89 def self.class.read_inheritable_attribute 'buttons' || [] end |
#cache? ⇒ Boolean
97 |
# File 'app/core/reporter.rb', line 97 def cache?; true; end |
#channel_title ⇒ Object
85 86 87 |
# File 'app/core/reporter.rb', line 85 def channel_title return 'Latest news from %s' / name.humanize end |
#latest_headline ⇒ Object
99 100 101 |
# File 'app/core/reporter.rb', line 99 def latest_headline return latest_headlines.first end |
#name ⇒ Object
81 82 83 |
# File 'app/core/reporter.rb', line 81 def name return self.class.reporter_name end |
#params_for(rid) ⇒ Object
93 94 95 |
# File 'app/core/reporter.rb', line 93 def params_for(rid) {:controller => 'report', :action => 'show', :reporter => name, :id => rid} end |