Skip to content

Commit

Permalink
Adds ERXPartial.init(). #602
Browse files Browse the repository at this point in the history
Here we add an init() method which subclasses (that is, partial
entities) can override. We also implement init() in
ERXPartialGenericRecord, and have it call init() on all the partial
entities it knows about. This works exactly the same way as
awakeFromInsertion(), for example.
  • Loading branch information
paulhoadley committed Aug 7, 2014
1 parent f9651ef commit ddd34c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,15 @@ public Object validateValueForKey(Object value, String key) throws NSValidation.
throw exception.exceptionWithObjectAndKey(this, key);
}
}

/**
* Delegated from the base entity. A partial entity can override this method
* to perform object initialisation. It will be called when the base
* entity's {@code init()} method is called.
*
* @param editingContext
* this object's {@link EOEditingContext}
*/
protected void init(EOEditingContext editingContext) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ public void awakeFromInsertion(EOEditingContext editingContext) {
}
}

@Override
protected void init(EOEditingContext editingContext) {
super.init(editingContext);
// Call init() on all partial entities
for (ERXPartial partial : _partials()) {
partial.init(editingContext);
}
}

@Override
public void awakeFromFetch(EOEditingContext editingContext) {
super.awakeFromFetch(editingContext);
Expand Down

0 comments on commit ddd34c2

Please sign in to comment.