5 // Created by Mike Mayo on 10/1/10.
6 // The OpenStack project is provided under the Apache 2.0 license.
10 #import "NSObject+NSCoding.h"
13 @implementation Flavor
15 @synthesize ram, disk;
17 #pragma mark - Serialization
19 - (void)encodeWithCoder:(NSCoder *)coder {
20 [self autoEncodeWithCoder:coder];
23 - (id)initWithCoder:(NSCoder *)coder {
26 [self autoDecode:coder];
31 - (id)copyWithZone:(NSZone *)zone {
32 Flavor *copy = [[Flavor allocWithZone:zone] init];
33 copy.identifier = self.identifier;
35 copy.disk = self.disk;
42 + (Flavor *)fromJSON:(NSDictionary *)dict {
43 Flavor *flavor = [[[Flavor alloc] initWithJSONDict:dict] autorelease];
44 flavor.ram = [[dict objectForKey:@"ram"] intValue];
45 flavor.disk = [[dict objectForKey:@"disk"] intValue];
50 #pragma mark - Comparison
52 // flavors should be sorted by RAM instead of name
53 - (NSComparisonResult)compare:(Flavor *)aFlavor {
54 return [[NSNumber numberWithInt:self.ram] compare:[NSNumber numberWithInt:aFlavor.ram]];