ad_manager_api/lib/ad_manager_api/pql_statement_utils.rb
def values()
      # values_array is an Ad-Manager-compliant list of values of the following
      # form: [:key => ..., :value => {:xsi_type => ..., :value => ...}]
      values_array = @values.map do |key, value|
        raise 'Missing value in StatementBuilder.' if value.nil?
        raise 'Misconfigured value in StatementBuilder.' unless value.is_a? Hash
        raise 'Value cannot be nil on StatementBuilder.' if value[:value].nil?
        raise 'Missing value type for %s.' % key if value[:xsi_type].nil?
        unless VALUE_TYPES.values.include?(value[:xsi_type])
          raise 'Unknown value type for %s.' % key
        end
        if value[:xsi_type] == 'SetValue'
          if value[:value].map {|v| v.class}.to_set.size > 1
            raise 'Cannot pass more than one type in set variable, %s.' % key
          end
        end
        if value[:xsi_type] == 'DateTimeValue'
          unless value[:value][:time_zone_id]
            raise 'Missing timezone on DateTimeValue variable, %s.' %key
          end
        end
        {:key => key.to_s(), :value => value}
      end
      return values_array
    end
def values()
      # values_array is an Ad-Manager-compliant list of values of the following
      # form: [:key => ..., :value => {:xsi_type => ..., :value => ...}]
      values_array = @values.map do |key, value|
        raise 'Missing value in StatementBuilder.' if value.nil?
        raise 'Misconfigured value in StatementBuilder.' unless value.is_a? Hash
        raise 'Value cannot be nil on StatementBuilder.' if value[:value].nil?
        raise 'Missing value type for %s.' % key if value[:xsi_type].nil?
        unless VALUE_TYPES.values.include?(value[:xsi_type])
          raise 'Unknown value type for %s.' % key
        end
        if value[:xsi_type] == 'SetValue'
          if value[:value].map {|v| v.class}.to_set.size > 1
            raise 'Cannot pass more than one type in set variable, %s.' % key
          end
        end
        if value[:xsi_type] == 'DateTimeValue'
          unless value[:value][:time_zone_id]
            raise 'Missing timezone on DateTimeValue variable, %s.' %key
          end
        end
        {:key => key.to_s(), :value => value}
      end
      return values_array
    end
def values ( ) # values_array is an Ad-Manager-compliant list of values of the following # form: [:key => ..., :value => {:xsi_type => ..., :value => ...}] values_array = @values . map do | key , value | raise 'Missing value in StatementBuilder.' if value . nil? raise 'Misconfigured value in StatementBuilder.' unless value . is_a? Hash raise 'Value cannot be nil on StatementBuilder.' if value [ :value ] . nil? raise 'Missing value type for %s.' % key if value [ :xsi_type ] . nil? unless VALUE_TYPES . values . include? ( value [ :xsi_type ] ) raise 'Unknown value type for %s.' % key end if value [ :xsi_type ] == 'SetValue' if value [ :value ] . map { | v | v . class } . to_set . size > 1 raise 'Cannot pass more than one type in set variable, %s.' % key end end if value [ :xsi_type ] == 'DateTimeValue' unless value [ :value ] [ :time_zone_id ] raise 'Missing timezone on DateTimeValue variable, %s.' % key end end { :key => key . to_s ( ) , :value => value } end return values_array end
Get values as an array, the format the Ad Manager API expects.
Get values as an array the format the Ad Manager API expects .