Handles attr with dot notation TODO write lots of tests for this helper Note: this lives outside the Data prototype for now so it can be used by the helper in DataService as well
427208
function _objectByAttribute(obj, attr, map, action) {
    var subAttrs = attr.split(".");
    var attrValue = obj;
    for (var i = 0; i < subAttrs.length; i++) {
      attrValue = attrValue[subAttrs[i]];
      if (attrValue === undefined) {
        return;
      }
    }

    if ($.isArray(attrValue)) {
      // TODO implement this when we actually need it
    }
    else if ($.isPlainObject(attrValue)) {
      for (var key in attrValue) {
        var val = attrValue[key];
        if (!map[key]) {
          map[key] = {};
        }
        if (action === "DELETED") {
          delete map[key][val];
        }
        else {
          map[key][val] = obj;
        }
      }
    }
    else {
      if (action === "DELETED") {
        delete map[attrValue];
      }
      else {
        map[attrValue] = obj;
      }
    }
  }
407450
def string(attr, metadata={})
      add_attribute(attr, :string, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", arg.nil? ? nil : arg.to_s)
      end
    end
904125
def check_attr(self, pos, attrs):
        """"""

        for at in attrs:
            (ns, local_name) = self.split_qname(at)
            if ns is None:
                error.err_add(self.ctx.errors, pos,
                              'UNEXPECTED_ATTRIBUTE', local_name)
            elif ns == yin_namespace:
                error.err_add(self.ctx.errors, pos,
                              'UNEXPECTED_ATTRIBUTE', "{"+at)
948067
function handleAttributeContext(attrNode, context) {
    if (!attrNode.type && attrNode.inherit !== 'inherit') attrNode.type = 'string';

    if (attrNode.map) {
        Object.keys(attrNode.map).forEach(mappingName => {
            const mapping = attrNode.map[mappingName];

            Object.keys(mapping).forEach(dataSourceName => {
                if (!context.dataSourceAttributes[dataSourceName]) {
                    throw new ImplementationError(
                        `Unknown DataSource "${dataSourceName}" in map${context.errorContext}`
                    );
                }

                context.dataSourceAttributes[dataSourceName].push(mapping[dataSourceName]);
            });
        });

        if ('value' in attrNode) {
            throw new ImplementationError(
                'Static "value" in combination with "map" makes no sense' + context.errorContext
            );
        }
    }
}
1116294
function parseAttributes(attrStr) {
    var reAttributes = /([^=<>\"\'\s]+)\s*(?:=\s*["']?([^"']*)["']?)?/g;
    var result = {};
    var match;

    if (attrStr) {
        while (match = reAttributes.exec(attrStr)) {
            result[match[1]] = match[2] || true;
        }
    }

    return result;
}
698027
function condenseDataAttrs(attrs) {
		var out = [], data = null;
		var reData = /^data-/i;
		attrs.forEach(function(attr) {
			if (reData.test(attr.name)) {
				if (!data) {
					data = [];
					out.push({
						name: 'data',
						value: data
					});
				}

				data.push(utils.extend({}, attr, {name: attr.name.replace(reData, '')}));
			} else {
				out.push(attr);
			}
		});

		return out;
	}
754371
def attrs
      atrs = {
        :object_type => "object-type-#{obj_type}", :permission_id => 'manage',
        :name => name, :field_type => 'text', :is_required => false,
        :is_primary => true
      }

      if !id.nil?
        atrs.merge!(:field_id => id)
      end

      atrs
    end
1327447
def decimal(attr, metadata={})
      add_attribute(attr, :decimal, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", arg.nil? ? nil : BigDecimal.new(arg.to_s))
      end
    end
643175
function assertString(attr, data) {
  if (data === null || data === undefined) {
    return null;
  }

  if (typeof data !== 'string') {
    throw new ParseError(`Attribute ${attr} must be of type "string"`);
  }

  return data;
}
32434
function attr(obj, key) {
    if (!obj[key]) {
      return '';
    }
    var val = obj[key];
    if (val === true) {
      return key;
    }
    return key + '="' + obj[key] + '"';
  }
1080890
def attributes=(attrs = {})
      attrs.each do |attr_name, value|
        setter = "#{attr_name}="
        send(setter, value)
      end
    end
70407
def _generate_dom_attrs(attrs, allow_no_value=True):
    
    for attr in iterate_items(attrs):
        if isinstance(attr, basestring):
            attr = (attr, True)
        key, value = attr
        if value is None:
            continue
        if value is True and not allow_no_value:
            value = key  # E.g. <option checked="true" />
        if value is True:
            yield True  # E.g. <option checked />
        else:
            yield '%s="%s"' % (key, value.replace('"', '\\"'))
551969
function Attr(model, value, mutator) {
        var _this = _super.call(this, model, value, mutator) /* istanbul ignore next */ || this;
        _this.value = value;
        return _this;
    }
662014
protected void validateValueType(String attrName, Object value) {
    if (value == null) {
      return;
    }

    Attribute attr = entityType.getAttribute(attrName);
    if (attr == null) {
      throw new UnknownAttributeException(entityType, attrName);
    }

    AttributeType dataType = attr.getDataType();
    switch (dataType) {
      case BOOL:
        if (!(value instanceof Boolean)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Boolean.class.getSimpleName(),
                  attrName));
        }
        break;
      case CATEGORICAL:
        // expected type is FileMeta. validation is not possible because molgenis-data does not
        // depend on molgenis-file
      case FILE:
      case XREF:
        if (!(value instanceof Entity)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Entity.class.getSimpleName(),
                  attrName));
        }
        break;
      case CATEGORICAL_MREF:
      case MREF:
      case ONE_TO_MANY:
        if (!(value instanceof Iterable)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Iterable.class.getSimpleName(),
                  attrName));
        }
        break;
      case COMPOUND:
        throw new IllegalArgumentException(
            format("Unexpected data type [%s] for attribute: [%s]", dataType.toString(), attrName));
      case DATE:
        if (!(value instanceof LocalDate)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  LocalDate.class.getSimpleName(),
                  attrName));
        }
        break;
      case DATE_TIME:
        if (!(value instanceof Instant)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Instant.class.getSimpleName(),
                  attrName));
        }
        break;
      case DECIMAL:
        if (!(value instanceof Double)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Double.class.getSimpleName(),
                  attrName));
        }
        if (((Double) value).isNaN()) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] for type [%s] is not allowed for attribute: [%s]",
                  value.toString(), Double.class.getSimpleName(), attrName));
        }
        break;
      case EMAIL:
      case ENUM:
      case HTML:
      case HYPERLINK:
      case SCRIPT:
      case STRING:
      case TEXT:
        if (!(value instanceof String)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  String.class.getSimpleName(),
                  attrName));
        }
        break;
      case INT:
        if (!(value instanceof Integer)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Integer.class.getSimpleName(),
                  attrName));
        }
        break;
      case LONG:
        if (!(value instanceof Long)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Long.class.getSimpleName(),
                  attrName));
        }
        break;
      default:
        throw new UnexpectedEnumException(dataType);
    }
  }
1094019
function (el, data_attr_name) {
        data_attr_name = data_attr_name || 'options';
        var opts = {}, ii, p, opts_arr,
            data_options = function (el) {
              var namespace = Foundation.global.namespace;

              if (namespace.length > 0) {
                return el.data(namespace + '-' + data_attr_name);
              }

              return el.data(data_attr_name);
            };

        var cached_options = data_options(el);

        if (typeof cached_options === 'object') {
          return cached_options;
        }

        opts_arr = (cached_options || ':').split(';');
        ii = opts_arr.length;

        function isNumber (o) {
          return !isNaN (o - 0) && o !== null && o !== '' && o !== false && o !== true;
        }

        function trim (str) {
          if (typeof str === 'string') {
            return $.trim(str);
          }
          return str;
        }

        while (ii--) {
          p = opts_arr[ii].split(':');
          p = [p[0], p.slice(1).join(':')];

          if (/true/i.test(p[1])) {
            p[1] = true;
          }
          if (/false/i.test(p[1])) {
            p[1] = false;
          }
          if (isNumber(p[1])) {
            if (p[1].indexOf('.') === -1) {
              p[1] = parseInt(p[1], 10);
            } else {
              p[1] = parseFloat(p[1]);
            }
          }

          if (p.length === 2 && p[0].length > 0) {
            opts[trim(p[0])] = trim(p[1]);
          }
        }

        return opts;
      }
149782
function(attr) {
      var html = this._escapedAttributes[attr];
      if (html) {
        return html;
      }
      var val = this.attributes[attr];
      var escaped;
      if (Parse._isNullOrUndefined(val)) {
        escaped = '';
      } else {
        escaped = _.escape(val.toString());
      }
      this._escapedAttributes[attr] = escaped;
      return escaped;
    }
880746
function(attr) {
      var startIndex, endIndex,
        i = 0,
        hasEndBracket = true,
        indices = [];
      startIndex = attr.indexOf('[', i);
      while (startIndex > 0 && hasEndBracket) {
         endIndex = attr.indexOf(']', i);
         indices.push(parseInt(attr.substring(startIndex + 1, endIndex), 10));
         i = endIndex + 1;
         hasEndBracket = i > 0;
         startIndex = attr.indexOf('[', i);
      }
      return indices;
    }