Sha256: 3b409b5815bd8eec5316c4d180922f56d563645e628912704437d022035c285b

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'time'

module RTurk
  class Assignment
    attr_reader :id, :source

    def initialize(id, source = nil)
      @id, @source = id, source
    end

    def bonus_payments
      RTurk::GetBonusPayments(:assignment_id => id).payments
    end

    def approve!(feedback = nil)
      RTurk::ApproveAssignment(:assignment_id => self.id, :feedback => feedback)
    end

    def approve_rejected!(feedback = nil)
      RTurk::ApproveRejectedAssignment(:assignment_id => self.id, :feedback => feedback)
    end

    def reject!(reason)
      RTurk::RejectAssignment(:assignment_id => self.id, :feedback => reason)
    end

    def bonus!(amount, reason)
      RTurk::GrantBonus(:assignment_id => self.id, :worker_id => self.worker_id, :amount => amount, :feedback => reason)
    end

    def worker
      RTurk::Worker.new(self.worker_id)
    end

    def submitted?
      status == 'Submitted'
    end

    def approved?
      status == 'Approved'
    end

    def rejected?
      status == 'Rejected'
    end

    def method_missing(method, *args)
      if self.source.respond_to?(method)
        self.source.send(method, *args)
      else
        super
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rturk-2.12.1 lib/rturk/adapters/assignment.rb
rturk-2.12.0 lib/rturk/adapters/assignment.rb
rturk-2.11.3 lib/rturk/adapters/assignment.rb
rturk-2.11.2 lib/rturk/adapters/assignment.rb
rturk-2.11.1 lib/rturk/adapters/assignment.rb
rturk-2.11.0 lib/rturk/adapters/assignment.rb