mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:52:45 +08:00
adjust API
This commit is contained in:
parent
89d5e8ab4b
commit
f2099c3811
|
@ -6,11 +6,11 @@ class TopicList
|
|||
cattr_accessor :preloaded_custom_fields
|
||||
self.preloaded_custom_fields = Set.new
|
||||
|
||||
def self.on_preload(blk)
|
||||
def self.on_preload(&blk)
|
||||
(@preload ||= Set.new) << blk
|
||||
end
|
||||
|
||||
def self.cancel_preload(blk)
|
||||
def self.cancel_preload(&blk)
|
||||
if @preload
|
||||
@preload.delete blk
|
||||
if @preload.length == 0
|
||||
|
|
|
@ -36,12 +36,12 @@ describe TopicList do
|
|||
preloaded_topic = true
|
||||
end
|
||||
|
||||
TopicList.on_preload(preloader)
|
||||
TopicList.on_preload(&preloader)
|
||||
|
||||
topic_list.topics
|
||||
expect(preloaded_topic).to eq(true)
|
||||
|
||||
TopicList.cancel_preload(preloader)
|
||||
TopicList.cancel_preload(&preloader)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user