Replaced delegator methods with Forwardable def_delegator in Topic
This commit is contained in:
parent
cd3f2a5973
commit
23d8f5fec7
|
@ -10,6 +10,16 @@ class Topic < ActiveRecord::Base
|
||||||
include ActionView::Helpers::SanitizeHelper
|
include ActionView::Helpers::SanitizeHelper
|
||||||
include RateLimiter::OnCreateRecord
|
include RateLimiter::OnCreateRecord
|
||||||
include Trashable
|
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!, :notify_regular!
|
||||||
|
def_delegator :notifier, :muted!, :notify_muted!
|
||||||
|
def_delegator :notifier, :toggle_mute, :toggle_mute
|
||||||
|
|
||||||
def self.max_sort_order
|
def self.max_sort_order
|
||||||
2**31 - 1
|
2**31 - 1
|
||||||
|
@ -21,14 +31,6 @@ class Topic < ActiveRecord::Base
|
||||||
@featured_users ||= TopicFeaturedUsers.new(self)
|
@featured_users ||= TopicFeaturedUsers.new(self)
|
||||||
end
|
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)
|
def trash!(trashed_by=nil)
|
||||||
update_category_topic_count_by(-1) if deleted_at.nil?
|
update_category_topic_count_by(-1) if deleted_at.nil?
|
||||||
super(trashed_by)
|
super(trashed_by)
|
||||||
|
@ -561,34 +563,12 @@ class Topic < ActiveRecord::Base
|
||||||
@topic_notifier ||= TopicNotifier.new(self)
|
@topic_notifier ||= TopicNotifier.new(self)
|
||||||
end
|
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)
|
def muted?(user)
|
||||||
if user && user.id
|
if user && user.id
|
||||||
notifier.muted?(user.id)
|
notifier.muted?(user.id)
|
||||||
end
|
end
|
||||||
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)
|
def auto_close_days=(num_days)
|
||||||
@ignore_category_auto_close = true
|
@ignore_category_auto_close = true
|
||||||
set_auto_close(num_days)
|
set_auto_close(num_days)
|
||||||
|
|
Loading…
Reference in New Issue