Initializes the object
 @param [Hash] attributes Model attributes in the form of hash
 Show invalid properties with the reasons. Usually used together with valid?
 @return Array for valid properies with the reasons
512417
def list_invalid_properties
      invalid_properties = Array.new
      if !@display_name.nil? && @display_name.to_s.length > 255
        invalid_properties.push("invalid value for 'display_name', the character length must be smaller than or equal to 255.")
      end

      if !@email_address.nil? && @email_address.to_s.length > 255
        invalid_properties.push("invalid value for 'email_address', the character length must be smaller than or equal to 255.")
      end

      if !@phone_number.nil? && @phone_number.to_s.length > 16
        invalid_properties.push("invalid value for 'phone_number', the character length must be smaller than or equal to 16.")
      end

      return invalid_properties
    end
57992
def inspect
      attrs = []
      attrs << ['key', @key.inspect] unless @key.nil?
      attrs << ['value', @value.inspect] unless @value.nil?
      model.attributes.map do |attr, default|
        val = read_attribute(attr)
        attrs << [attr.to_s, val.inspect] unless val.nil?
      end
      attrs.sort!
      attrs.unshift([:id, id]) unless new?
      sprintf('#<%s %s>', model, attrs.map { |a| a.join(': ') }.join(', '))
    end
935655
def hbs_attributes
      s = self.class.class_variable_get(:@@serialize)
      if s[:merge]
        attrs = s[:attrs] + self.attributes.keys
      else
        attrs = s[:attrs]
      end
      attrs.collect{|attr| attr.to_sym}.uniq
    end
1285574
def inspect
      # We check defined?(@attributes) not to issue warnings if the object is
      # allocated but not initialized.
      inspection = if defined?(@attributes) && @attributes
        self.class.attribute_names.collect do |name|
          if has_attribute?(name)
            attr = _read_attribute(name)
            value = if attr.nil?
              attr.inspect
            else
              attr = format_for_inspect(attr)
              inspection_filter.filter_param(name, attr)
            end
            "#{name}: #{value}"
          end
        end.compact.join(", ")
      else
        "not initialized"
      end

      "#<#{self.class} #{inspection}>"
    end
986056
def attributes=(attributes)
      model = self.model
      attributes.each do |name, value|
        case name
          when String, Symbol
            if model.allowed_writer_methods.include?(setter = "#{name}=")
              __send__(setter, value)
            else
              raise ArgumentError, "The attribute '#{name}' is not accessible in #{model}"
            end
          when Associations::Relationship, Property
            # only call a public #typecast (e.g. on Property instances)
            if name.respond_to?(:typecast)
              value = name.typecast(value)
            end
            self.persistence_state = persistence_state.set(name, value)
        end
      end
    end
255093
function(attributes) {
    if (!attributes) attributes = {};

    this.eClass = attributes.eClass;
    this.values = {};

    // stores function for eOperations.
    attributes._ && (this._ = attributes._);

    // Initialize values according to the eClass features.
    initValues(this);
    setValues(this, attributes);
    initOperations(this);

    return this;
}
1039442
def reverse_assign_attributes(attributes_hash)
      attributes_to_assign = attributes_hash.keys.reject{|_attribute_name| attribute_present?(_attribute_name) }

      assign_attributes(attributes_hash.slice(attributes_to_assign))
    end
334100
def add_attributes hash
      if hash.kind_of? Hash
        hash.each_pair {|key, value| @attributes[key] = value }
      elsif hash.kind_of? Array
        hash.each { |value| @attributes[ value[0] ] = value[1] }
      end
    end
199582
def parse_attribute_values
      values = []
      each_property do |name, value|
        values << AttributeValue.new(name, value)
      end

      DEFAULTS.each do |default|
        if values.find { |v| v.attribute.name == default.attribute.name }.nil?
          values << default
        end
      end

      values
    end
274459
def attributes= (attrs)
      attrs.each_pair do |name, value|
        field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
        setter = "#{name}=".to_sym
        if respond_to?(setter)
          send(setter, value)
        else
          write_attribute(field, value, self)
        end
      end
    end
1076973
protected function initAttributes() {
		$vars = get_object_vars($this->_xml->attributes());
			
		$this->_attributes = empty($vars) ? [] : $vars['@attributes'];
	}
799858
def initialize_errors(errors_hash)
				return if errors_hash.nil?
				
				if errors_hash[:ad_api_error].is_a?(Array)
					self.errors = []
					errors_hash[:ad_api_error].each do |aae|
						self.errors << BingAdsApi::AdApiError.new(aae)
					end
				elsif errors_hash[:ad_api_error].is_a?(Hash)
					self.errors = [BingAdsApi::AdApiError.new(errors_hash[:ad_api_error])]
				end
			end
1008536
def valid?
    @errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
    
    self.class._module.required_fields.each do |attribute|
      valid_attribute?(attribute)
    end
    
    # for rails compatibility
    def @errors.full_messages
      # After removing attributes without errors, flatten the error hash, repeating the name of the attribute before each message:
      # e.g. {'name' => ['cannot be blank', 'is too long'], 'website' => ['is not valid']}
      # will become 'name cannot be blank, name is too long, website is not valid
      self.inject([]){|memo, obj| memo.concat(obj[1].inject([]){|m, o| m << "#{obj[0].to_s.humanize} #{o}" })}
    end
    
    # Rails needs each attribute to be present in the error hash (if the attribute has no error, it has [] as a value)
    # Redefine the [] method for the errors hash to return [] instead of nil is the hash doesn't contain the key
    class << @errors
      alias :old_key_lookup :[]
      def [](key)
        old_key_lookup(key) || Array.new
      end
    end
    
    @errors.size == 0
  end
1022242
def attributes
      attrs = {}
      attribute_names.each { |name| attrs[name] = read_attribute(name) }
      attrs
    end
370257
public function firstOrInitialize(array $attributes = [])
    {
        $model = $this->first();
        if (!$model) {
            $model = $this->initialize($attributes);
        }
        return $model;
    }
692847
def instantiate_model_from_attributes_hash(model_class, attributes)
      model_class.new.tap do |model|
        model.instance_variable_set :@dealing_platform, self

        attributes.each do |attribute, value|
          next unless model.class.valid_attribute? attribute

          type = model.class.attribute_type attribute
          value = instantiate_models type, value if type < Model

          set_model_attribute_value model, attribute, value
        end
      end
    end
888987
def list_invalid_properties
      invalid_properties = []
      if @style.nil?
        invalid_properties.push("invalid value for 'style', style cannot be nil.")
      end

      if @transparency.nil?
        invalid_properties.push("invalid value for 'transparency', transparency cannot be nil.")
      end

      if @weight.nil?
        invalid_properties.push("invalid value for 'weight', weight cannot be nil.")
      end

      return invalid_properties
    end