Class: Amazon::WebServices::MechanicalTurk
- Inherits:
-
Object
- Object
- Amazon::WebServices::MechanicalTurk
- Includes:
- Util::Logging
- Defined in:
- lib/amazon/webservices/mechanical_turk.rb
Constant Summary collapse
- SOFTWARE_NAME =
'MTurkRubySDK'- SANDBOX =
'mechanicalturk.sandbox.amazonaws.com'- PROD =
'mechanicalturk.amazonaws.com'
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ MechanicalTurk
constructor
By default, MechanicalTurk will operate on the MechanicalTurk Sandbox.
- #method_missing(method, *args) ⇒ Object
Methods included from Util::Logging
Constructor Details
#initialize(args = {}) ⇒ MechanicalTurk
By default, MechanicalTurk will operate on the MechanicalTurk Sandbox. To run against the main site, pass :Host => :Production into the constructor.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/amazon/webservices/mechanical_turk.rb', line 23 def initialize(args={}) name = args[:Name] || 'AWSMechanicalTurkRequester' software = args.has_key?(:SoftwareName) ? "#{SOFTWARE_NAME}, #{args[:SoftwareName]}" : "#{SOFTWARE_NAME}" @host = case args[:Host].to_s when /^Prod/i PROD when /^Sandbox/i,"" SANDBOX else args[:Host].to_s end ssl = ( args[:UseSSL].nil? ? true : args[:UseSSL] ) newargs = args.merge( :Name => name, :SoftwareName => software, :Host => @host, :UseSSL => ssl) if args[:Transport].to_s =~ /^SOAP/i unless Util::SOAPTransport.canSOAP? log "Unable to use SOAP transport. Falling back to REST." args[:Transport] = :REST end end transport = case args[:Transport] when :SOAP,/^SOAP/i getSOAPTransport(newargs) when :REST,/^REST/i getRESTTransport(newargs) else require 'amazon/webservices/util/soap_transport.rb' allowOverride( 'Transport', args[:Transport], newargs ) { |a| if Util::RESTTransport.canPost? getRESTTransport(newargs) elsif Util::SOAPTransport.canSOAP? getSOAPTransport(newargs) else getRESTTransport(newargs) end } end newargs.merge!( :Transport => transport ) log "Generating relay with following args: #{newargs.inspect}" relay = allowOverride('Relay',args[:Relay],newargs) { |a| Amazon::WebServices::Util::AmazonAuthenticationRelay.new(a) } newargs.merge!( :Relay => relay ) log "Generating error handler with the following args: #{newargs.inspect}" @errorHandler = allowOverride('ErrorHandler',args[:ErrorHandler],newargs) { |a| Amazon::WebServices::MTurk::MechanicalTurkErrorHandler.new(a) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
69 70 71 72 |
# File 'lib/amazon/webservices/mechanical_turk.rb', line 69 def method_missing(method,*args) log "Sending request: #{method} #{args.inspect}" @errorHandler.dispatch(method,*args) end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
67 68 69 |
# File 'lib/amazon/webservices/mechanical_turk.rb', line 67 def host @host end |