Skip to content

Commit

Permalink
Add check to only create association once
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed Jun 25, 2011
1 parent 93d7dda commit ecb38e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mesh/model/Entity.as
Expand Up @@ -109,12 +109,18 @@ package mesh.model

protected function hasOne(property:String, clazz:Class, options:Object = null):HasOneAssociation
{
return associate(property, new HasOneDefinition(reflect.clazz, property, clazz, options).createProxy(this));
if (!_associations.hasOwnProperty(property)) {
_associations[property] = new HasOneDefinition(reflect.clazz, property, clazz, options).createProxy(this);
}
return _associations[property];
}

protected function hasMany(property:String, clazz:Class, options:Object = null):HasManyAssociation
{
return associate(property, new HasManyDefinition(reflect.clazz, property, clazz, options).createProxy(this));
if (!_associations.hasOwnProperty(property)) {
_associations[property] = new HasManyDefinition(reflect.clazz, property, clazz, options).createProxy(this);
}
return _associations[property];
}

/**
Expand Down

0 comments on commit ecb38e6

Please sign in to comment.