// 
//  CategoryMethod.m
//  Flash2
//
//  Created by Nicholas Matsakis on 4/6/08.
//  Copyright 2008 Nicholas Matsakis. All rights reserved.
//

#import "CategoryMethod.h"

#import "Relationship.h"
#import "Category.h"
#import "FScript/FScript.h"
#import "OxNSDocument.h"

@interface NSObject (HokeyFscript)
- errorStr;
@end

@implementation CategoryMethod 

#pragma mark Core Data Properties and Relationships

@dynamic kind;
@dynamic name;
@dynamic text;
@dynamic definesRelationship;
@dynamic category;

#pragma mark Validation Methods

- (BOOL) validateText:(id *)ioValue error:(NSError **)outError 
{
    @try {
        NSString *value = *ioValue;
        [value asBlock]; 
    }
    @catch (NSException *exc) {
        // this API seems to be private which is rather hokey...
        id blockStackElem = [[exc userInfo] objectForKey:@"FScriptBlockStack"];
        id errorStr = [blockStackElem errorStr];
        NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errorStr
                                                             forKey:NSLocalizedDescriptionKey];
        *outError = [NSError errorWithDomain:DEFAULT_ERROR_DOMAIN
                                        code:0
                                    userInfo:userInfo];
        return NO;
    }
    return YES; // if compilation is successful... 
}

@end
