Class: CrowdFlower::Worker
- Inherits:
-
Base
- Object
- Base
- CrowdFlower::Worker
show all
- Defined in:
- lib/crowdflower/worker.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#last_response
Instance Method Summary
collapse
Methods inherited from Base
connect, #connect, connect!, connect_config!, connect_domain!, connection, #connection, delete, get, post, put, verify_response
Constructor Details
#initialize(job) ⇒ Worker
Returns a new instance of Worker.
5
6
7
8
9
|
# File 'lib/crowdflower/worker.rb', line 5
def initialize( job )
super job.connection
@job = job
connect
end
|
Instance Attribute Details
#job ⇒ Object
Returns the value of attribute job.
3
4
5
|
# File 'lib/crowdflower/worker.rb', line 3
def job
@job
end
|
Instance Method Details
#approve(worker_id) ⇒ Object
23
24
25
|
# File 'lib/crowdflower/worker.rb', line 23
def approve( worker_id )
connection.put( "#{resource_uri}/#{worker_id}/approve", :headers => { "Content-Length" => "0" } )
end
|
#ban(worker_id) ⇒ Object
31
32
33
|
# File 'lib/crowdflower/worker.rb', line 31
def ban( worker_id )
connection.put( "#{resource_uri}/#{worker_id}/ban", :headers => { "Content-Length" => "0" } )
end
|
#bonus(worker_id, amount, reason = nil) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/crowdflower/worker.rb', line 15
def bonus( worker_id, amount, reason=nil )
params = {
:amount => amount,
:reason => reason
}
connection.post( "#{resource_uri}/#{worker_id}/bonus", :body => params )
end
|
#deban(worker_id) ⇒ Object
35
36
37
|
# File 'lib/crowdflower/worker.rb', line 35
def deban( worker_id )
connection.put( "#{resource_uri}/#{worker_id}/deban", :headers => { "Content-Length" => "0" } )
end
|
#deflag(worker_id) ⇒ Object
51
52
53
|
# File 'lib/crowdflower/worker.rb', line 51
def deflag( worker_id )
connection.put( "#{resource_uri}/#{worker_id}/deflag", :headers => { "Content-Length" => "0" } )
end
|
#flag(worker_id, reason = nil) ⇒ Object
47
48
49
|
# File 'lib/crowdflower/worker.rb', line 47
def flag( worker_id, reason = nil )
connection.put( "#{resource_uri}/#{worker_id}/flag", :body => { :reason => reason }, :headers => { "Content-Length" => "0" } )
end
|
#notify(worker_id, subject, message) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/crowdflower/worker.rb', line 39
def notify( worker_id, subject, message )
params = {
:subject => subject,
:message => message
}
connection.post( "#{resource_uri}/#{worker_id}/notify", :query => params )
end
|
#reject(worker_id) ⇒ Object
27
28
29
|
# File 'lib/crowdflower/worker.rb', line 27
def reject( worker_id )
connection.put( "#{resource_uri}/#{worker_id}/reject", :headers => { "Content-Length" => "0" } )
end
|
#resource_uri ⇒ Object
11
12
13
|
# File 'lib/crowdflower/worker.rb', line 11
def resource_uri
"/jobs/#{@job.id}/workers"
end
|