/*
        Copyright (c) 1996, NeXT Software, Inc.
        All rights reserved.

        You may freely copy, distribute and reuse the code in this example.
        NeXT disclaims any warranty of any kind, expressed or implied,
        as to its fitness for any particular use.
*/
#import "OneObjectDataSource.h"

@implementation OneObjectDataSource

- initWithGlobalID:(EOGlobalID *)gid editingContext:(EOEditingContext *)context;
{
    [super init];
    obj = [[context faultForGlobalID:gid editingContext:context] retain];
    [context retain];
    return self;
}

- (void)dealloc
{
    [[obj editingContext] autorelease];
    [obj release];
    [super dealloc];
}

- (NSArray *)fetchObjects
{
    return [NSArray arrayWithObject:obj];
}

- (EOEditingContext *)editingContext
{
    return [obj editingContext];
}

- (EODataSource *)dataSourceQualifiedByKey:(NSString *)key
{
    return [[[EODetailDataSource alloc] initWithMasterDataSource:self detailKey:key] autorelease];
}

- (EOClassDescription *)classDescriptionForObjects
{
    return [obj classDescription];
}

@end
