You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
758 B
42 lines
758 B
// |
|
// RACValueTransformer.m |
|
// ReactiveObjC |
|
// |
|
// Created by Josh Abernathy on 3/6/12. |
|
// Copyright (c) 2012 GitHub, Inc. All rights reserved. |
|
// |
|
|
|
#import "RACValueTransformer.h" |
|
|
|
@interface RACValueTransformer () |
|
@property (nonatomic, copy) id (^transformBlock)(id value); |
|
@end |
|
|
|
|
|
@implementation RACValueTransformer |
|
|
|
|
|
#pragma mark NSValueTransformer |
|
|
|
+ (BOOL)allowsReverseTransformation { |
|
return NO; |
|
} |
|
|
|
- (id)transformedValue:(id)value { |
|
return self.transformBlock(value); |
|
} |
|
|
|
|
|
#pragma mark API |
|
|
|
@synthesize transformBlock; |
|
|
|
+ (instancetype)transformerWithBlock:(id (^)(id value))block { |
|
NSCParameterAssert(block != NULL); |
|
|
|
RACValueTransformer *transformer = [[self alloc] init]; |
|
transformer.transformBlock = block; |
|
return transformer; |
|
} |
|
|
|
@end
|
|
|