From bbd79aafd10fa7fa9ed1d0798b1b59465674bb17 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 29 Aug 2013 11:45:27 -0400 Subject: [PATCH] Revert "Replaced delegator methods with Forwardable def_delegator in Topic" This reverts commit 3ed037940f464bc1ab32c0751dfe7df476ac31cb. --- app/models/topic.rb | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index f297edbe54c..5fe6a17bd70 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -10,16 +10,6 @@ class Topic < ActiveRecord::Base include ActionView::Helpers::SanitizeHelper include RateLimiter::OnCreateRecord include Trashable - extend Forwardable - - def_delegator :featured_users, :user_ids, :featured_user_ids - def_delegator :featured_users, :choose, :feature_topic_users - - def_delegator :notifier, :watch!, :notify_watch! - def_delegator :notifier, :tracking!, :notify_tracking! - def_delegator :notifier, :regular!, :notifiy_regular! - def_delegator :notifier, :muted!, :notify_muted! - def_delegator :notifier, :toggle_mute, :toggle_mute def self.max_sort_order 2**31 - 1 @@ -31,6 +21,14 @@ class Topic < ActiveRecord::Base @featured_users ||= TopicFeaturedUsers.new(self) end + def featured_user_ids + featured_users.user_ids + end + + def feature_topic_users(args={}) + featured_users.choose(args) + end + def trash!(trashed_by=nil) update_category_topic_count_by(-1) if deleted_at.nil? super(trashed_by) @@ -563,12 +561,34 @@ class Topic < ActiveRecord::Base @topic_notifier ||= TopicNotifier.new(self) end + # notification stuff + def notify_watch!(user) + notifier.watch! user + end + + def notify_tracking!(user) + notifier.tracking! user + end + + def notify_regular!(user) + notifier.regular! user + end + + def notify_muted!(user) + notifier.muted! user + end + def muted?(user) if user && user.id notifier.muted?(user.id) end end + # Enable/disable the mute on the topic + def toggle_mute(user_id) + notifier.toggle_mute user_id + end + def auto_close_days=(num_days) @ignore_category_auto_close = true set_auto_close(num_days)