public function set(array $data, array $options = array())
{
$defaults = array('init' => false);
$options += $defaults;
$cast = $schema = $this->schema();
foreach ($data as $key => $val) {
unset($this->_increment[$key]);
if (strpos($key, '.')) {
$this->_setNested($key, $val);
continue;
}
if ($cast) {
$pathKey = $this->_pathKey;
$model = $this->_model;
$parent = $this;
$val = $schema->cast($this, $key, $val, compact('pathKey', 'model', 'parent'));
}
if ($val instanceof self) {
$val->_exists = $options['init'] && $this->_exists;
$val->_pathKey = ($this->_pathKey ? "{$this->_pathKey}." : '') . $key;
$val->_model = $val->_model ?: $this->_model;
$val->_schema = $val->_schema ?: $this->_schema;
}
$this->_updated[$key] = $val;
}
}