lib/rturk/builders/qualification_builder.rb in rturk-2.3.6 vs lib/rturk/builders/qualification_builder.rb in rturk-2.4.0

- old
+ new

@@ -32,17 +32,12 @@ qualifier[:QualificationTypeId] = type elsif type.is_a?(Symbol) qualifier[:QualificationTypeId] = types[type] end if opts.is_a?(Hash) - qualifier[:Comparator] = COMPARATORS[opts.keys.first] - value = opts.values.first - if value.to_s.match(/[A-Z]./) - qualifier[:Country] = value - else - qualifier[:IntegerValue] = value - end + qualifier[:RequiredToPreview] = opts['RequiredToPreview'].to_s unless opts['RequiredToPreview'].nil? + qualifier.merge!(build_comparator(opts)) elsif opts == true || opts == false qualifier[:IntegerValue] = opts == true ? 1 : 0 qualifier[:Comparator] = COMPARATORS[:eql] end qualifier @@ -59,9 +54,26 @@ end def types # Could use this later to add other TYPES programatically TYPES + end + + private + + def build_comparator(opts) + qualifier = {} + opts.each do |k,v| + if COMPARATORS.has_key?(k) + qualifier[:Comparator] = COMPARATORS[k] + if v.to_s.match(/[A-Z]./) + qualifier[:Country] = v + else + qualifier[:IntegerValue] = v + end + end + end + qualifier end end end