/*
        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 "CreditCard.h"

@implementation CreditCard

- (void)awakeFromInsertionInEditingContext:(EOEditingContext *)ctx
{
    // Set default values for newly inserted objects in awake.
    // No need to do willChange here since we're just being inserted
    if (!authorizationDate) 
        authorizationDate = [[NSCalendarDate date] retain];
    if (!limit) 
        limit = [[NSDecimalNumber decimalNumberWithString:@"150"] retain];
}

- (NSDecimalNumber *)limit {
    return limit;
}

- (void)dealloc
{
    [authorizationDate release];
    [authorizationNum release];
    [cardNumber release];
    [cardType release];
    [member release];
    [expirationDate release];
    [limit release];
    [super dealloc];
}

- description { return [self eoDescription]; }

- (NSString *)inverseForRelationshipKey:(NSString *)relationshipKey
{
    // It's normally not necessary to explicitly define this method,
    // since the EOModel does it for us (via EOClassDescription).  In
    // this case EORelationship can't spot the inverse because we don't
    // join on the same set of keys in the member and creditCard relationships
    if ([relationshipKey isEqual:@"member"])
        return @"creditCard";
    return [super inverseForRelationshipKey:relationshipKey];
}

@end
