Files
RestKit/Code/ObjectMapping/RKObjectSerializer.h
Blake Watters 670234b775 Added support for polymorphic object mapping (Github #105, #244). This enables you to dynamically map objects to different destination classes or using different mapping strategies via configuration or callbacks. See Docs/Object Mapping.md for details.
Other changes include:
* Eliminated the RKObjectFactory protocol and implementations. Object mapping instances themselves are
now responsible for instantiating target objects for mapping.
* Introduced RKObjectAbstractMapping superclass for RKObjectMapping and RKObjectPolymorphicMapping.
* Updated example applications to use block object loaders (RKTwitter and RKTwitterCoreData)
* Refactored method signatures of RKObjectMapper, RKObjectMapping, and RKObjectMappingProvider to reflect the
existence of abstract mapping types. This was necessary to make polymorphic mappings integrate cleanly.
* Fixed overlap in RestKit error domains between network and object mapping. fixes #208
2011-07-30 16:00:36 -04:00

52 lines
1.9 KiB
Objective-C

//
// RKObjectSerializer.h
// RestKit
//
// Created by Blake Watters on 5/2/11.
// Copyright 2011 Two Toasters. All rights reserved.
//
#import "RKObjectMapping.h"
#import "RKObjectMappingOperation.h"
#import "../Network/RKRequestSerializable.h"
/**
Performs a serialization of an object and its relationships back into
a dictionary representation according to the mappings specified. The
transformed object is then enclosed in an RKRequestSerializable representation
that is suitable for inclusion in an RKRequest.
*/
@interface RKObjectSerializer : NSObject <RKObjectMappingOperationDelegate> {
id _object;
RKObjectMapping* _mapping;
}
@property (nonatomic, readonly) id object;
@property (nonatomic, readonly) RKObjectMapping* mapping;
+ (id)serializerWithObject:(id)object mapping:(RKObjectMapping*)mapping;
- (id)initWithObject:(id)object mapping:(RKObjectMapping*)mapping;
/**
Return a serialized representation of the source object by applying an object mapping
with a target object type of NSMutableDictionary. The serialized object will contain attributes
and relationships composed of simple KVC compliant Cocoa types.
*/
- (NSMutableDictionary*)serializedObject:(NSError**)error;
/**
Return a serialized representation of the source object by mapping it into a NSMutableDictionary and
then encoding it into the destination MIME Type via an instance of RKParser that is registered
for the specified MIME Type
*/
- (NSString*)serializedObjectForMIMEType:(NSString*)MIMEType error:(NSError**)error;
/**
Return a request serialization for the source object by mapping it to an NSMutableDictionary, encoding
the data via a parser into the specified MIME Type, and wrapping it into a serializable format that can
be used as the params of an RKRequest or RKObjectLoader
*/
- (id<RKRequestSerializable>)serializationForMIMEType:(NSString*)mimeType error:(NSError**)error;
@end