Merge pull request #1392 from einarj/use_topic_delegators

Replaced delegator methods with Forwardable def_delegator in Topic
This commit is contained in:
Robin Ward 2013-08-29 07:55:35 -07:00
commit 37b4df3009
1 changed files with 10 additions and 30 deletions

View File

@ -10,6 +10,16 @@ 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
@ -21,14 +31,6 @@ 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)
@ -561,34 +563,12 @@ 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)