Skip to content

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
Conflicts:
	FastEasyMapping/Source/Core/Mapping/FEMMapping.h
	FastEasyMapping/Source/Core/Mapping/FEMMapping.m
	FastEasyMappingTests/Mapping Provider/MappingProvider.m
	FastEasyMappingTests/Mapping Provider/MappingProviderNative.m
  • Loading branch information
zen committed Sep 1, 2015
2 parents 354273e + a299775 commit 0e656bc
Show file tree
Hide file tree
Showing 67 changed files with 2,663 additions and 2,104 deletions.
1 change: 1 addition & 0 deletions FastEasyMapping.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Pod::Spec.new do |spec|
spec.frameworks = 'CoreData'

spec.source_files = 'FastEasyMapping/Source/**/*.{h,m}'
spec.private_header_files = 'FastEasyMapping/Source/Extensions/**/*.h'
end
270 changes: 135 additions & 135 deletions FastEasyMapping.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
//
// Created by zen on 15/06/14.
// Copyright (c) 2014 Yalantis. All rights reserved.
//
// For License please refer to LICENSE file in the root of FastEasyMapping project

@import Foundation;
#import <Foundation/Foundation.h>

@class FEMAssignmentPolicyMetadata;
@class FEMRelationshipAssignmentContext;

typedef id (^FEMAssignmentPolicy)(FEMAssignmentPolicyMetadata *metadata);
typedef __nullable id (^FEMAssignmentPolicy)(FEMRelationshipAssignmentContext * __nonnull context);

OBJC_EXTERN FEMAssignmentPolicy FEMAssignmentPolicyAssign;
OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyAssign;

OBJC_EXTERN FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge;
OBJC_EXTERN FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge;
OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge;
OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge;

OBJC_EXTERN FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace;
OBJC_EXTERN FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace;
OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace;
OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace;
56 changes: 26 additions & 30 deletions FastEasyMapping/Source/Core/Assignment Policy/FEMAssignmentPolicy.m
Original file line number Diff line number Diff line change
@@ -1,64 +1,60 @@
//
// Created by zen on 15/06/14.
// Copyright (c) 2014 Yalantis. All rights reserved.
//
// For License please refer to LICENSE file in the root of FastEasyMapping project

#import "FEMAssignmentPolicy.h"

#import "FEMAssignmentPolicyMetadata.h"
#import "FEMRelationshipAssignmentContext.h"
#import "FEMExcludableCollection.h"
#import "FEMMergeableCollection.h"

@import CoreData;

FEMAssignmentPolicy FEMAssignmentPolicyAssign = ^id (FEMAssignmentPolicyMetadata *metadata) {
return metadata.targetValue;
FEMAssignmentPolicy FEMAssignmentPolicyAssign = ^id(FEMRelationshipAssignmentContext * context) {
return context.targetRelationshipValue;
};

FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge = ^id (FEMAssignmentPolicyMetadata *metadata) {
return metadata.targetValue ?: metadata.existingValue;
FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge = ^id(FEMRelationshipAssignmentContext *context) {
return context.targetRelationshipValue ?: context.sourceRelationshipValue;
};

FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge = ^id (FEMAssignmentPolicyMetadata *metadata) {
if (!metadata.targetValue) return metadata.existingValue;
FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge = ^id(FEMRelationshipAssignmentContext *context) {
if (!context.targetRelationshipValue) return context.sourceRelationshipValue;

NSCAssert(
[metadata.targetValue conformsToProtocol:@protocol(FEMMergeableCollection)],
[context.targetRelationshipValue conformsToProtocol:@protocol(FEMMergeableCollection)],
@"Collection %@ should support protocol %@",
NSStringFromClass([metadata.targetValue class]),
NSStringFromClass([context.targetRelationshipValue class]),
NSStringFromProtocol(@protocol(FEMMergeableCollection))
);

return [metadata.targetValue collectionByMergingObjects:metadata.existingValue];
return [context.targetRelationshipValue collectionByMergingObjects:context.sourceRelationshipValue];
};

FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace = ^id (FEMAssignmentPolicyMetadata *metadata) {
if (metadata.existingValue && ![metadata.existingValue isEqual:metadata.targetValue]) {
[metadata.context deleteObject:metadata.existingValue];
FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace = ^id(FEMRelationshipAssignmentContext *context) {
if (context.sourceRelationshipValue && ![context.sourceRelationshipValue isEqual:context.targetRelationshipValue]) {
[context deleteRelationshipObject:context.sourceRelationshipValue];
}

return metadata.targetValue;
return context.targetRelationshipValue;
};

FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace = ^id (FEMAssignmentPolicyMetadata *metadata) {
if (!metadata.existingValue) return metadata.targetValue;
FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace = ^id(FEMRelationshipAssignmentContext *context) {
if (!context.sourceRelationshipValue) return context.targetRelationshipValue;

if (metadata.targetValue) {
if (context.targetRelationshipValue) {
NSCAssert(
[metadata.existingValue conformsToProtocol:@protocol(FEMExcludableCollection)],
[context.sourceRelationshipValue conformsToProtocol:@protocol(FEMExcludableCollection)],
@"Collection %@ should support protocol %@",
NSStringFromClass([metadata.targetValue class]),
NSStringFromClass([context.targetRelationshipValue class]),
NSStringFromProtocol(@protocol(FEMExcludableCollection))
);

for (id object in [(id<FEMExcludableCollection>)metadata.existingValue collectionByExcludingObjects:metadata.targetValue]) {
[metadata.context deleteObject:object];
id objectsToDelete = [(id <FEMExcludableCollection>) context.sourceRelationshipValue collectionByExcludingObjects:context.targetRelationshipValue];
for (id object in objectsToDelete) {
[context deleteRelationshipObject:object];
}
} else {
for (id object in metadata.existingValue) {
[metadata.context deleteObject:object];
for (id object in context.sourceRelationshipValue) {
[context deleteRelationshipObject:object];
}
}

return metadata.targetValue;
return context.targetRelationshipValue;
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Created by zen on 13/05/15.
// Copyright (c) 2015 Yalantis. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "FEMRelationshipAssignmentContext.h"

@interface FEMRelationshipAssignmentContext (Internal)

@property (nonatomic, strong) id destinationObject;
@property (nonatomic, strong) FEMRelationship *relationship;

@property (nonatomic, strong) id sourceRelationshipValue;
@property (nonatomic, strong) id targetRelationshipValue;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Created by zen on 13/05/15.
// Copyright (c) 2015 Yalantis. All rights reserved.
//

#import <Foundation/Foundation.h>

@class FEMRelationship, FEMObjectStore, FEMRelationshipAssignmentContext;

@protocol FEMRelationshipAssignmentContextDelegate <NSObject>
@required

- (void)assignmentContext:(nonnull FEMRelationshipAssignmentContext *)context deletedObject:(nonnull id)object;

@end


@interface FEMRelationshipAssignmentContext: NSObject

@property (nonatomic, unsafe_unretained, readonly, nonnull) FEMObjectStore *store;
- (nonnull instancetype)initWithStore:(nonnull FEMObjectStore *)store;

@property (nonatomic, strong, readonly, nonnull) id destinationObject;
@property (nonatomic, strong, readonly, nonnull) FEMRelationship *relationship;

@property (nonatomic, strong, readonly, nullable) id sourceRelationshipValue;
@property (nonatomic, strong, readonly, nullable) id targetRelationshipValue;

- (void)deleteRelationshipObject:(nonnull id)object;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Created by zen on 13/05/15.
// Copyright (c) 2015 Yalantis. All rights reserved.
//

#import "FEMRelationshipAssignmentContext.h"
#import "FEMRelationshipAssignmentContext+Internal.h"

#import "FEMRelationship.h"
#import "FEMObjectStore.h"

@interface FEMRelationshipAssignmentContext ()

@property (nonatomic, strong) id destinationObject;
@property (nonatomic, strong) FEMRelationship *relationship;

@property (nonatomic, strong) id sourceRelationshipValue;
@property (nonatomic, strong) id targetRelationshipValue;

@property (nonatomic, unsafe_unretained) id<FEMRelationshipAssignmentContextDelegate> delegate;

@end

@implementation FEMRelationshipAssignmentContext

- (instancetype)initWithStore:(FEMObjectStore *)store {
self = [super init];
if (self) {
_store = store;
self.delegate = store;
}

return self;
}

- (void)deleteRelationshipObject:(id)object {
[self.delegate assignmentContext:self deletedObject:object];
}

@end

@implementation FEMRelationshipAssignmentContext (Internal)

@dynamic destinationObject;
@dynamic relationship;
@dynamic sourceRelationshipValue;
@dynamic targetRelationshipValue;

@end
26 changes: 0 additions & 26 deletions FastEasyMapping/Source/Core/Cache/FEMCache.h

This file was deleted.

Loading

0 comments on commit 0e656bc

Please sign in to comment.