Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b820eb20
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b820eb20
编写于
9月 14, 2014
作者:
A
Abdelkader Boudih
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify test_adapter
上级
e3a65c6d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
43 deletion
+4
-43
activejob/lib/active_job/queue_adapters/test_adapter.rb
activejob/lib/active_job/queue_adapters/test_adapter.rb
+4
-43
未找到文件。
activejob/lib/active_job/queue_adapters/test_adapter.rb
浏览文件 @
b820eb20
module
ActiveJob
module
QueueAdapters
class
TestAdapter
attr_accessor
(
:perform_enqueued_jobs
)
{
false
}
attr_accessor
(
:perform_enqueued_at_jobs
)
{
false
}
delegate
:name
,
to: :class
attr_accessor
(
:perform_enqueued_jobs
,
:perform_enqueued_at_jobs
)
attr_writer
(
:enqueued_jobs
,
:performed_jobs
)
# Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
def
enqueued_jobs
@enqueued_jobs
||=
[]
end
# Allows you to overwrite the default enqueued jobs store from an array to some
# other object. If you just want to clear the store,
# call ActiveJob::QueueAdapters::TestAdapter.enqueued_jobs.clear.
#
# If you place another object here, please make sure it responds to:
#
# * << (message)
# * clear
# * length
# * size
# * and other common Array methods
def
enqueued_jobs
=
(
val
)
@enqueued_jobs
=
val
end
# Provides a store of all the performed jobs with the TestAdapter so you can check them.
def
performed_jobs
@performed_jobs
||=
[]
end
# Allows you to overwrite the default performed jobs store from an array to some
# other object. If you just want to clear the store,
# call ActiveJob::QueueAdapters::TestAdapter.performed_jobs.clear.
#
# If you place another object here, please make sure it responds to:
#
# * << (message)
# * clear
# * length
# * size
# * and other common Array methods
def
performed_jobs
=
(
val
)
@performed_jobs
=
val
end
def
enqueue
(
job
)
if
perform_enqueued_jobs
?
if
perform_enqueued_jobs
performed_jobs
<<
{
job:
job
.
class
,
args:
job
.
arguments
,
queue:
job
.
queue_name
}
job
.
perform_now
else
...
...
@@ -55,22 +25,13 @@ def enqueue(job)
end
def
enqueue_at
(
job
,
timestamp
)
if
perform_enqueued_at_jobs
?
if
perform_enqueued_at_jobs
performed_jobs
<<
{
job:
job
.
class
,
args:
job
.
arguments
,
queue:
job
.
queue_name
,
at:
timestamp
}
job
.
perform_now
else
enqueued_jobs
<<
{
job:
job
.
class
,
args:
job
.
arguments
,
queue:
job
.
queue_name
,
at:
timestamp
}
end
end
private
def
perform_enqueued_jobs?
perform_enqueued_jobs
end
def
perform_enqueued_at_jobs?
perform_enqueued_at_jobs
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录