Attach properties to the document
427874
function attachProperties(schema, paths) {
  paths.forEach(path => {
    const props = path.options.attach.properties;

    if (props[path.path]) {
      (props[path.path].on || []).forEach(on => {

        /**
        * Setup post callbacks
        */
        schema.post(on, function(documents, next) {
          asArray(documents).forEach(function(doc) {
            paths.forEach(function(path) {
              doc[props[path.path].as] = path.enumValues;
            });
          });

          next();
        });
      });
    }
  });
}
971943
function addPropertiesToText(text, properties, filePath) {

        if (!properties.length) {
            return text;
        }

        var placeRegexp = patterns.getPlacePattern(properties[0].isFromPrototype),
            matchedData = placeRegexp.exec(text);

        // Can`t find properties place
        if (!matchedData) {
            grunt.log.error("No " + (properties[0].isFromPrototype ? "prototype" : "inline") + " properties place definition at " + filePath +
                '   (properties: ' + properties.map(function (p) {return p.name + ' at ' + p.filePath; }).join(', ') + ')');

            return text;
        }

        // don`t use .replace with "$" at replacement text
        return text.replace(placeRegexp, function () {
            return (matchedData[1] ?  matchedData[1] + ',' : '') +
                ('\n\n' + concatProperties(properties))
                    .replace(/\n(?!\r?\n)/g, '\n' + matchedData[2]);
        });
    }
467117
def add_property(self, prop, objects=()):
        """"""
        self._properties.add(prop)
        self._objects |= objects
        self._pairs.update((o, prop) for o in objects)
791611
function (data) {
    // Add property to hold internal values
    Object.defineProperty(this, '_', {
        enumerable: false,
        configurable: false,
        writable: false,
        value: {
            dt: this._clone(data),
            ev: {},
            df: {},
            sp: false,
            ct: 0
        }
    });
    // Assign keys
    for (var key in this._.dt) {
        this._addProperty(key);
    }
}
813881
public function attach($document)
    {
        if (isset($this->connection)) {
            $document = $this->connection->unmarshall($document);
        }

        // wrap document as NObject instance to make sure it can be override by hooks
        $document = new NObject($document);

        $this->applyHook('attaching', $document);

        if (isset($this->options['model'])) {
            $Model = $this->options['model'];
            $model = new $Model($document->toArray(), array(
                'collection' => $this,
            ));
        } else {
            $model = new Model($document->toArray(), array(
                'collection' => $this,
            ));
        }

        $this->applyHook('attached', $model);

        return $model;
    }
304669
function applyPropDoclets(props, propName) {
  let prop = props[propName];
  let doclets = prop.doclets;
  let value;

  // the @type doclet to provide a prop type
  // Also allows enums (oneOf) if string literals are provided
  // ex: @type {("optionA"|"optionB")}
  if (doclets.type) {
    value = cleanDocletValue(doclets.type);
    prop.type.name = value;

    if (value[0] === '(') {
      value = value.substring(1, value.length - 1).split('|');

      prop.type.value = value;
      prop.type.name = value.every(isLiteral) ? 'enum' : 'union';
    }
  }

  // Use @required to mark a prop as required
  // useful for custom propTypes where there isn't a `.isRequired` addon
  if (doclets.required) {
    prop.required = true;
  }

  // Use @defaultValue to provide a prop's default value
  if (doclets.defaultValue) {
    prop.defaultValue = cleanDocletValue(doclets.defaultValue);
  }
}
428597
def add_property(self, pred, obj):
        
        pred = Uri(pred)
        try:
            self[pred].append(obj)
        # except AttributeError:
        #     new_list = [self[pred]]
        #     new_list.append(obj)
        #     self[pred] = new_list
        except KeyError:
            try:
                new_prop = self.properties[pred]
            except AttributeError:
                self.properties = {}
                self.add_property(pred, obj)
                return
            except KeyError:
                try:
                    new_prop = MODULE.rdfclass.properties[pred]
                except KeyError:
                    new_prop = MODULE.rdfclass.make_property({},
                                                      pred, self.class_names)
                try:
                    self.properties[pred] = new_prop
                except AttributeError:
                    self.properties = {pred: new_prop}
            init_prop = new_prop(self, get_attr(self, "dataset"))
            setattr(self,
                    pred,
                    init_prop)
            self[pred] = init_prop
            self[pred].append(obj)
        if self.dataset:
            self.dataset.add_rmap_item(self, pred, obj)
1066641
function populatePropertyFor (documents, next) {
    if (this._mongooseOptions.lean) {
      asArray(documents).forEach(function(doc) {
        paths.forEach(function(path) {
          try {
            const splitted = path.path.split('.');
            const key      = splitted.shift();
            const insert   = { values: path.enumValues };
            const value    = doc[key];

            insert.value = determineValue(splitted, value);
            doc[key]     = nest(splitted, insert);
          } catch (error) { return next(error); }
        });
      });
    }

    next();
  }
572939
function addCustomFeatureProperties(entity) {
  for (var i = 0; i < customProperties.length; i++) {
    if (entity.propertyNames.indexOf(customProperties[i]) === -1) {
      entity.addProperty(customProperties[i]);
    }
  }
}
689328
private void addFieldToDocument(Object object, Document document, java.lang.reflect.Field field, String colName,
        String indexName) {
        try {
            Object obj = PropertyAccessorHelper.getObject(object, field);
            // String str =
            // String value = (obj == null) ? null : obj.toString();
            if (obj != null) {
                Field luceneField =
                    new Field(getCannonicalPropertyName(indexName, colName), obj.toString(), Field.Store.YES,
                        Field.Index.ANALYZED_NO_NORMS);

                document.add(luceneField);
            } else {
                LOG.warn("value is null for field" + field.getName());
            }
        } catch (PropertyAccessException e) {
            LOG.error("Error in accessing field, Caused by:" + e.getMessage());
            throw new LuceneIndexingException("Error in accessing field:" + field.getName(), e);
        }
    }
738109
private synchronized void appendXMLProperty(Document doc, Element conf,
	                                            String propertyName) {
		// skip writing if given property name is empty or null
		if (!Strings.isNullOrEmpty(propertyName)) {
			String value = properties.getProperty(propertyName);
			if (value != null) {
				Element propNode = doc.createElement("property");
				conf.appendChild(propNode);

				Element nameNode = doc.createElement("name");
				nameNode.appendChild(doc.createTextNode(propertyName));
				propNode.appendChild(nameNode);

				Element valueNode = doc.createElement("value");
				valueNode.appendChild(doc.createTextNode(
						properties.getProperty(propertyName)));
				propNode.appendChild(valueNode);

				Element finalNode = doc.createElement("final");
				finalNode.appendChild(doc.createTextNode(
						String.valueOf(finalParameters.contains(propertyName))));
				propNode.appendChild(finalNode);

				if (updatingResource != null) {
					String[] sources = updatingResource.get(propertyName);
					if(sources != null) {
						for(String s : sources) {
							Element sourceNode = doc.createElement("source");
							sourceNode.appendChild(doc.createTextNode(s));
							propNode.appendChild(sourceNode);
						}
					}
				}
			}
		}
	}
659545
def render_property(property):
	""""""
	# This ain't the prettiest thing, but it should get the job done.
	# I don't think we have anything more elegant available at bosh-manifest-generation time.
	# See https://docs.pivotal.io/partners/product-template-reference.html for list.
	if 'type' in property and property['type'] in PROPERTY_FIELDS:
		fields = {}
		for field in PROPERTY_FIELDS[property['type']]:
			if type(field) is tuple:
				fields[field[0]] = '(( .properties.{}.{} ))'.format(property['name'], field[1])
			else:
				fields[field] = '(( .properties.{}.{} ))'.format(property['name'], field)
		out = { property['name']: fields }
	else:
		if property.get('is_reference', False):
			out = { property['name']: property['default'] }
		else:
			out = { property['name']: '(( .properties.{}.value ))'.format(property['name']) }
	return out
152684
function addProperty(sourceData, propertiesGroups, filePath) {

        var group = propertiesUtils.getGroup(sourceData[2], propertiesGroups),
            propertyName,
            data,
            propertyDefinitionWithoutObjectName;

        if (!group) {
            grunt.log.error('Object ' + sourceData[2] + ' without init file');
            return;
        }

        grunt.verbose.ok(sourceData[2]);

        // generate property data
        propertyDefinitionWithoutObjectName = sourceData[2].replace(group.pattern, '').replace(/^\./, '');
        propertyName = propertyDefinitionWithoutObjectName.replace(/^prototype\./i, '');
        data = {
            name:     propertyName,
            source:   sourceData[3].replace(/(^[\r\n\s]+|[\r\n\s;]+$)/g, ''),
            comment:  sourceData[1] || '',
            type:     propertiesUtils.isFunction(sourceData[3]) ? 'function' : 'object',
            isPublic: propertiesUtils.isPublic(propertyName),
            isFromPrototype: propertiesUtils.isFromPrototype(propertyDefinitionWithoutObjectName),
            filePath: filePath
        };

        // add property data to prototype or inline array
        group[(data.isFromPrototype ? 'prototypeProperties' : 'inlineProperties')].push(data);
    }
301441
function attach(listener) {
    if (!listener) return;
    if (!listener[CONTEXTS_SYMBOL]) listener[CONTEXTS_SYMBOL] = Object.create(null);

    listener[CONTEXTS_SYMBOL][thisSymbol] = {
      namespace : namespace,
      context   : namespace.active
    };
  }
1072869
private void writeProperties() throws IOException
   {
      writeAttributeTypes("property_types", ProjectField.values());
      writeFields("property_values", m_projectFile.getProjectProperties(), ProjectField.values());
   }
1224672
function loadAttachments (doc, root, prefix) {
  doc.__attachments = doc.__attachments || []
  try {
    fs.statSync(root)
  } catch(e) {
    throw e
    throw new Error("Cannot stat file "+root)
  }
  doc.__attachments.push({root:root, prefix:prefix});
}
45035
def define_properties(obj, props):
    """"""
    cls = obj.__class__
    dct = {
        '__doc__': cls.__doc__
    }

    for name, defn in list(props.items()):
        if is_callable(defn):
            defn = property(defn)
        elif not hasattr(defn, '__get__'):
            defn = property(*defn)
        dct[name] = defn

    obj.__class__ = type(cls.__name__, (cls, ), dct)