Class: TopicPostersSummary
- Inherits:
-
Object
- Object
- TopicPostersSummary
- Defined in:
- app/models/topic_posters_summary.rb
Overview
This is used in topic lists
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Class Method Summary collapse
-
.translations ⇒ Object
localization is fast, but this allows us to avoid calling it in a loop which adds up.
Instance Method Summary collapse
-
#initialize(topic, options = {}) ⇒ TopicPostersSummary
constructor
A new instance of TopicPostersSummary.
- #summary ⇒ Object
Constructor Details
#initialize(topic, options = {}) ⇒ TopicPostersSummary
Returns a new instance of TopicPostersSummary.
18 19 20 21 22 |
# File 'app/models/topic_posters_summary.rb', line 18 def initialize(topic, = {}) @topic = topic @options = @translations = [:translations] || TopicPostersSummary.translations end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'app/models/topic_posters_summary.rb', line 16 def @options end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
16 17 18 |
# File 'app/models/topic_posters_summary.rb', line 16 def topic @topic end |
Class Method Details
.translations ⇒ Object
localization is fast, but this allows us to avoid calling it in a loop which adds up
7 8 9 10 11 12 13 14 |
# File 'app/models/topic_posters_summary.rb', line 7 def self.translations { original_poster: I18n.t(:original_poster), most_recent_poster: I18n.t(:most_recent_poster), frequent_poster: I18n.t(:frequent_poster), joiner: I18n.t(:poster_description_joiner), } end |
Instance Method Details
#summary ⇒ Object
24 25 26 |
# File 'app/models/topic_posters_summary.rb', line 24 def summary sorted_top_posters.compact.map(&method(:new_topic_poster_for)) end |