//
//  NSObject+YSRACDescription.m
//  ReactiveObjC
//
//  Created by Justin Spahr-Summers on 2013-05-13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import "NSObject+YSRACDescription.h"
#import "YSRACTuple.h"

@implementation NSValue (YSRACDescription)

- (NSString *)ysrac_description {
	return self.description;
}

@end

@implementation NSString (YSRACDescription)

- (NSString *)ysrac_description {
	return self.description;
}

@end

@implementation YSRACTuple (YSRACDescription)

- (NSString *)ysrac_description {
	if (getenv("YSRAC_DEBUG_SIGNAL_NAMES") != NULL) {
		return self.allObjects.description;
	} else {
		return @"(description skipped)";
	}
}

@end

NSString *YSRACDescription(id object) {
	if (getenv("YSRAC_DEBUG_SIGNAL_NAMES") != NULL) {
		if ([object respondsToSelector:@selector(ysrac_description)]) {
			return [object ysrac_description];
		} else {
			return [[NSString alloc] initWithFormat:@"<%@: %p>", [object class], object];
		}
	} else {
		return @"(description skipped)";
	}
}
