Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
This adds a root_object method which addresses issue #240.
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed Jan 22, 2013
1 parent 6b203cc commit d9b4830
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions enaml/core/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,21 @@ def receive_action(self, action, content):
#--------------------------------------------------------------------------
# Object Tree API
#--------------------------------------------------------------------------
def root_object(self):
""" Get the root object for this hierarchy.
Returns
-------
result : Object
The top-most object in the hierarchy to which this object
belongs.
"""
obj = self
while obj._parent is not None:
obj = obj._parent
return obj

def traverse(self, depth_first=False):
""" Yield all of the objects in the tree, from this object down.
Expand Down

0 comments on commit d9b4830

Please sign in to comment.