Sha256: 0eb6d41cdff7893876b5970e83f19c9520fc396a6756f1fc3c54910f6446d214

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

module CrowdFlower
  class Worker < Base
    attr_reader :job
    
    def initialize( job )
      super job.connection
      @job = job
      connect
    end
    
    def resource_uri
      "/jobs/#{@job.id}/workers"
    end
    
    def bonus( worker_id, amount, reason=nil )
      params = {
        :amount => amount,
        :reason => reason
      }
      connection.post( "#{resource_uri}/#{worker_id}/bonus", :body => params )
    end
    
    def approve( worker_id )
      connection.put( "#{resource_uri}/#{worker_id}/approve", :headers => { "Content-Length" => "0" } )
    end
    
    def reject( worker_id )
      connection.put( "#{resource_uri}/#{worker_id}/reject", :headers => { "Content-Length" => "0" } )
    end
    
    def ban( worker_id )
      connection.put( "#{resource_uri}/#{worker_id}/ban", :headers => { "Content-Length" => "0" } )
    end
    
    def deban( worker_id )
      connection.put( "#{resource_uri}/#{worker_id}/deban", :headers => { "Content-Length" => "0" } )
    end
    
    def notify( worker_id, subject, message )
      params = {
        :subject => subject,
        :message => message
      }
      connection.post( "#{resource_uri}/#{worker_id}/notify", :query => params )
    end
    
    def flag( worker_id, reason = nil )
      connection.put( "#{resource_uri}/#{worker_id}/flag", :body => { :reason => reason }, :headers => { "Content-Length" => "0" } )
    end
    
    def deflag( worker_id )
      connection.put( "#{resource_uri}/#{worker_id}/deflag",  :headers => { "Content-Length" => "0" } )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crowdflower-0.7.0 lib/crowdflower/worker.rb
crowdflower-0.6.8 lib/crowdflower/worker.rb
crowdflower-0.6.7 lib/crowdflower/worker.rb
crowdflower-0.6.3 lib/crowdflower/worker.rb