Skip to content

Commit

Permalink
add Object.ID() (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
srerickson authored Feb 14, 2025
1 parent 9549183 commit 44d6570
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ func (obj *Object) FS() FS {
return obj.fs
}

// ID returns obj's inventory ID if the obj exists (its inventory is not nil).
// If obj does not exist but was constructed with [Root.NewObject](), the ID
// used with [Root.NewObject]() is returned. Otherwise, it returns an empty
// string.
func (obj *Object) ID() string {
if obj.inventory != nil {
return obj.inventory.ID()
}
return obj.expectID
}

// Inventory returns the object's Inventory if it exists. If the object
// doesn't exist, it returns nil.
func (obj *Object) Inventory() Inventory {
Expand Down

0 comments on commit 44d6570

Please sign in to comment.