Skip to content

Instantly share code, notes, and snippets.

@aiwilliams
Created January 26, 2011 22:00
Show Gist options
  • Save aiwilliams/797564 to your computer and use it in GitHub Desktop.
Save aiwilliams/797564 to your computer and use it in GitHub Desktop.
api/v1/stop_dates.json
-----
[{"created_at":"2011-01-26T16:14:42Z","id":1,"stops_on":"2011-01-26","updated_at":"2011-01-26T16:14:42Z","truck_stops":[{"created_at":"2011-01-26T16:14:42Z","id":1,"notes":"Get your warm, delicious cupcakes in the Barnes & Noble parking lot.","stop_date_id":1,"stop_location_id":1,"stops_at":"2000-01-01T11:00:00Z","updated_at":"2011-01-26T16:14:42Z","stop_location":{"address":"201 Summit Boulevard Suite 100 Birmingham, AL","created_at":"2011-01-26T16:14:42Z","id":1,"title":"Barnes & Noble, The Summit","updated_at":"2011-01-26T16:14:42Z"}}]},{"created_at":"2011-01-26T16:14:42Z","id":2,"stops_on":"2011-01-27","updated_at":"2011-01-26T16:14:42Z","truck_stops":[{"created_at":"2011-01-26T16:14:42Z","id":2,"notes":"Yumm occurring, right in front!","stop_date_id":2,"stop_location_id":2,"stops_at":"2000-01-01T12:00:00Z","updated_at":"2011-01-26T16:14:42Z","stop_location":{"address":"4133 White Oak Drive Birmingham, AL","created_at":"2011-01-26T16:14:42Z","id":2,"title":"Primavera Coffee","updated_at":"2011-01-26T16:14:42Z"}},{"created_at":"2011-01-26T16:14:42Z","id":3,"notes":"We will be camped out in the parking circle. Come'n get it!","stop_date_id":2,"stop_location_id":3,"stops_at":"2000-01-01T13:00:00Z","updated_at":"2011-01-26T16:14:42Z","stop_location":{"address":"1911 Kentucky Ave Vestavia Hills, AL","created_at":"2011-01-26T16:14:42Z","id":3,"title":"The Rave Theater in Vestavia","updated_at":"2011-01-26T16:14:42Z"}},{"created_at":"2011-01-26T16:14:42Z","id":4,"notes":"","stop_date_id":2,"stop_location_id":4,"stops_at":"2000-01-01T14:00:00Z","updated_at":"2011-01-26T16:14:42Z","stop_location":{"address":"4700 US Highway 280 Birmingham, AL","created_at":"2011-01-26T16:14:42Z","id":4,"title":"Fresh Market","updated_at":"2011-01-26T16:14:42Z"}},{"created_at":"2011-01-26T16:14:42Z","id":5,"notes":"The most delicious place on earth is in the Publix parking lot.","stop_date_id":2,"stop_location_id":5,"stops_at":"2000-01-01T15:00:00Z","updated_at":"2011-01-26T16:14:42Z","stop_location":{"address":"410 Doug Baker Boulevard Birmingham, AL","created_at":"2011-01-26T16:14:42Z","id":5,"title":"Publix Lee Branch","updated_at":"2011-01-26T16:14:42Z"}}]}]
in DBStopDate.h
-----
@interface DBStopDate : RKObject {
NSSet* _truckStops;
}
@property (nonatomic, retain) NSSet* truckStops;
in DBStopDate.m
-----
@implementation DBStopDate
@synthesize stopDateID = _stopDateID;
@synthesize createdAt = _createdAt;
@synthesize truckStops = _truckStops;
+ (NSDictionary*)elementToPropertyMappings {
return [NSDictionary dictionaryWithKeysAndObjects:
@"id", @"stopDateID",
@"created_at", @"createdAt",
nil];
}
+ (NSDictionary*)elementToRelationshipMappings {
return [NSDictionary dictionaryWithKeysAndObjects:
@"truck_stops", @"truckStops",
nil];
}
- (NSString*)description {
return [NSString stringWithFormat:@"StopDate (ID: %@)", self.stopDateID];
}
@end
in DBTruckStop.m
-----
@implementation DBTruckStop
@synthesize truckStopID = _truckStopID;
@synthesize createdAt = _createdAt;
@synthesize stopLocation = _stopLocation;
@synthesize stopDate = _stopDate;
+ (NSDictionary*)elementToPropertyMappings {
return [NSDictionary dictionaryWithKeysAndObjects:
@"id", @"truckStopID",
@"created_at", @"createdAt",
nil];
}
+ (NSDictionary*)elementToRelationshipMappings {
return [NSDictionary dictionaryWithKeysAndObjects:
@"stop_date", @"stopDate",
@"stop_location", @"stopLocation",
nil];
}
- (NSString*)description {
return [NSString stringWithFormat:@"TruckStop (ID: %@)", self.truckStopID];
}
@end
mapper
-----
[mapper registerClass:[DBStopDate class] forElementNamed:@"stop_date"];
[mapper registerClass:[DBTruckStop class] forElementNamed:@"truck_stop"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment