Skip to content

Commit

Permalink
add strict schema for models
Browse files Browse the repository at this point in the history
  • Loading branch information
jrschumacher committed Apr 25, 2012
1 parent 77f0680 commit db4b4d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/BaseMongoRecord.php
Expand Up @@ -30,7 +30,9 @@ abstract class BaseMongoRecord extends CoreMongoRecord {
/**
* @var array
*/
protected $__meta = array();
protected $__meta = array(
'strict_schema' => FALSE
);

/**
* @uses stores the attributes for the record
Expand Down Expand Up @@ -469,6 +471,10 @@ protected function setter($attribute, $value = NULL) {
$this->{$method}($value);
}
else {
if($this->__meta['strict_schema'] === TRUE && !isset($this->attributes[$attribute])) {
return FALSE;
}

$this->attributes[$attribute] = $value;
}
}
Expand Down

0 comments on commit db4b4d1

Please sign in to comment.