class BingAdsApi::Errors::ApiException

This class encapsulates base class for API exceptions. More specific exceptions are generated based on Service WSDL.

Attributes

array_fields[R]

Public Class Methods

new(exception_fault) click to toggle source
# File lib/bing_ads_api/errors.rb, line 12
def initialize(exception_fault)
  @array_fields ||= []
  exception_fault.each { |key, value| set_field(key, value) }
end

Private Instance Methods

arrayize(object) click to toggle source

Makes sure object is an array

# File lib/bing_ads_api/errors.rb, line 28
def arrayize(object)
  return [] if object.nil?
  return object.is_a?(Array) ? object : [object]
end
is_array_field(field) click to toggle source

Should a field be forced to be an array

# File lib/bing_ads_api/errors.rb, line 34
def is_array_field(field)
  return @array_fields.include?(field.to_s)
end
set_field(field, value) click to toggle source

Sets instance’s property to a value if it is defined

# File lib/bing_ads_api/errors.rb, line 20
def set_field(field, value)
  if respond_to?(field)
    value = arrayize(value) if is_array_field(field)
    instance_variable_set("@#{field}", value)
  end
end