motion-yapper 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.travis.yml +2 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/motion-yapper.rb +1 -0
- data/lib/yapper.rb +3 -5
- data/lib/yapper/config.rb +2 -0
- data/lib/yapper/db.rb +105 -40
- data/lib/yapper/document.rb +7 -4
- data/lib/yapper/document/callbacks.rb +0 -7
- data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
- data/lib/yapper/document/relation.rb +29 -22
- data/lib/yapper/document/selection.rb +122 -54
- data/lib/yapper/extensions.rb +12 -24
- data/lib/yapper/settings.rb +43 -0
- data/lib/yapper/timestamps.rb +2 -0
- data/lib/yapper/version.rb +1 -1
- data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
- data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
- data/spec/integration/db_spec.rb +70 -0
- data/spec/integration/defaults_spec.rb +37 -0
- data/spec/integration/extensions_spec.rb +14 -0
- data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
- data/spec/integration/relation_spec.rb +4 -4
- data/vendor/Podfile.lock +9 -11
- data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
- data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
- data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
- data/vendor/Pods/.build/libPods.a +0 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
- data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
- data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
- data/vendor/Pods/Headers/____Pods-environment.h +15 -15
- data/vendor/Pods/Manifest.lock +9 -11
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
- data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
- data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
- data/vendor/Pods/Pods-environment.h +15 -15
- data/vendor/Pods/Pods.xcconfig +3 -3
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
- data/vendor/Pods/YapDatabase/README.md +3 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
- data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
- metadata +80 -108
- data/Gemfile.lock +0 -63
- data/lib/yapper/attachment.rb +0 -48
- data/lib/yapper/document/attachment.rb +0 -26
- data/lib/yapper/sync.rb +0 -134
- data/lib/yapper/sync/data.rb +0 -12
- data/lib/yapper/sync/event.rb +0 -194
- data/lib/yapper/sync/queue.rb +0 -164
- data/spec/integration/all_spec.rb +0 -40
- data/spec/integration/sync_spec.rb +0 -42
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
- data/vendor/Pods/AFNetworking/LICENSE +0 -19
- data/vendor/Pods/AFNetworking/README.md +0 -208
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
- data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
- data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
- data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
- data/vendor/Pods/Reachability/LICENCE.txt +0 -24
- data/vendor/Pods/Reachability/README.md +0 -65
- data/vendor/Pods/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Reachability/Reachability.m +0 -527
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7395ef1251cdd8864f3acb18c0a151766fd10835
|
4
|
+
data.tar.gz: 121948cad3cc4af4fa4e4ae0b8d6e979610eb645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6675d2d18eaef05d80678a3f22edc55ac5d4a908ee9b66c621ea31c9a7a4bd1048a0b02dd69e95ad7c02d064e0d6d97f57b4ec45e84d0fe99f12a166f302891b
|
7
|
+
data.tar.gz: a174b03c1edbb8ae5099e571ce9e8595e9fc2044384f176071777aeb911d4afcda3a7fc3f9d3dbb16a868a83cad22cd48c1c7d07645230024efda2d7c56662a0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
yapper [![Build Status](https://travis-ci.org/kareemk/yapper.png?branch=master)](https://travis-ci.org/kareemk/
|
1
|
+
yapper [![Build Status](https://travis-ci.org/kareemk/yapper.png?branch=master)](https://travis-ci.org/kareemk/yapper)
|
2
2
|
======
|
3
3
|
|
4
4
|
RubyMotion ORM for YapDatabase
|
data/Rakefile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'yapper'
|
data/lib/yapper.rb
CHANGED
@@ -14,9 +14,7 @@ Motion::Project::App.setup do |app|
|
|
14
14
|
app.detect_dependencies = false
|
15
15
|
|
16
16
|
app.pods do
|
17
|
-
pod 'YapDatabase' ,'~> 2.
|
18
|
-
pod 'AFNetworking' ,'~> 1.3.3'
|
19
|
-
pod 'Reachability' ,'~> 3.1.1'
|
17
|
+
pod 'YapDatabase' ,'~> 2.4'
|
20
18
|
pod 'CocoaLumberjack' ,'~> 1.6.5'
|
21
19
|
pod 'NSData+MD5Digest' ,'~> 1.0.0'
|
22
20
|
end
|
@@ -24,7 +22,7 @@ Motion::Project::App.setup do |app|
|
|
24
22
|
yap_patch = File.expand_path(File.join(File.dirname(__FILE__), '../vendor/YapDatabaseRubyMotion'))
|
25
23
|
app.vendor_project(yap_patch,
|
26
24
|
:static,
|
27
|
-
:bridgesupport_cflags =>
|
28
|
-
:cflags =>
|
25
|
+
:bridgesupport_cflags => "-I#{Dir.pwd}/vendor/Pods/Headers -fobjc-arc",
|
26
|
+
:cflags => "-I#{Dir.pwd}/vendor/Pods/Headers -fobjc-arc")
|
29
27
|
|
30
28
|
end
|
data/lib/yapper/config.rb
CHANGED
data/lib/yapper/db.rb
CHANGED
@@ -33,57 +33,74 @@ class Yapper::DB
|
|
33
33
|
block.call(db)
|
34
34
|
end
|
35
35
|
|
36
|
-
def execute(&block)
|
36
|
+
def execute(notifications={}, &block)
|
37
|
+
Notifications.track(notifications)
|
38
|
+
|
37
39
|
create_indexes!
|
38
40
|
|
39
|
-
|
40
|
-
unless self.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
self.txn.rollback
|
47
|
-
exception = e
|
48
|
-
ensure
|
49
|
-
self.txn = nil
|
50
|
-
end
|
41
|
+
result = nil
|
42
|
+
unless self.transaction
|
43
|
+
self.transaction = Transaction.new(self)
|
44
|
+
begin
|
45
|
+
result = transaction.run(&block)
|
46
|
+
ensure
|
47
|
+
self.transaction = nil
|
51
48
|
end
|
52
|
-
|
53
|
-
|
49
|
+
Notifications.trigger
|
54
50
|
else
|
55
|
-
result = block.call(self.txn)
|
51
|
+
result = block.call(self.transaction.txn)
|
56
52
|
end
|
57
53
|
|
58
|
-
raise exception if exception
|
59
54
|
result
|
60
55
|
end
|
61
56
|
|
62
57
|
def purge
|
63
|
-
|
58
|
+
Yapper::Settings.purge
|
59
|
+
@index_creation_required = true
|
60
|
+
create_indexes!
|
64
61
|
execute { |txn| txn.removeAllObjectsInAllCollections }
|
65
62
|
end
|
66
63
|
|
67
|
-
def
|
68
|
-
Thread.current[:
|
64
|
+
def transaction=(transaction)
|
65
|
+
Thread.current[:yapper_transaction] = transaction
|
66
|
+
end
|
67
|
+
|
68
|
+
def transaction
|
69
|
+
Thread.current[:yapper_transaction]
|
70
|
+
end
|
71
|
+
|
72
|
+
def index(model, args=[])
|
73
|
+
options = args.extract_options!
|
74
|
+
|
75
|
+
@index_creation_required = true
|
76
|
+
@indexes[model._type] ||= {}
|
77
|
+
|
78
|
+
args.each do |field|
|
79
|
+
options = model.fields[field]; raise "#{self._type}:#{field} not defined" unless options
|
80
|
+
type = options[:type]; raise "#{self._type}:#{field} must define type as its indexed" if type.nil?
|
81
|
+
|
82
|
+
@indexes[model._type][field] = { :type => type }
|
83
|
+
end
|
69
84
|
end
|
70
85
|
|
71
|
-
def
|
72
|
-
|
86
|
+
def connection
|
87
|
+
Dispatch.once { @connection ||= db.newConnection }
|
88
|
+
@connection
|
73
89
|
end
|
74
90
|
|
75
|
-
def
|
76
|
-
@
|
77
|
-
@
|
91
|
+
def db
|
92
|
+
Dispatch.once { @db ||= YapDatabase.alloc.initWithPath(document_path) }
|
93
|
+
@db
|
78
94
|
end
|
79
95
|
|
96
|
+
|
80
97
|
private
|
81
98
|
|
82
|
-
def create_indexes!
|
83
|
-
return
|
99
|
+
def create_indexes!
|
100
|
+
return unless @index_creation_required
|
84
101
|
|
85
102
|
@@queue.sync do
|
86
|
-
return
|
103
|
+
return unless @index_creation_required
|
87
104
|
|
88
105
|
@indexes.each do |collection, fields|
|
89
106
|
setup = YapDatabaseSecondaryIndexSetup.alloc.init
|
@@ -96,6 +113,8 @@ class Yapper::DB
|
|
96
113
|
YapDatabaseSecondaryIndexTypeInteger
|
97
114
|
when 'Time'
|
98
115
|
YapDatabaseSecondaryIndexTypeInteger
|
116
|
+
when 'Boolean'
|
117
|
+
YapDatabaseSecondaryIndexTypeInteger
|
99
118
|
else
|
100
119
|
raise "Invalid type #{type}"
|
101
120
|
end
|
@@ -111,6 +130,8 @@ class Yapper::DB
|
|
111
130
|
value = case options[:type].to_s
|
112
131
|
when 'Time'
|
113
132
|
_attrs[field].to_i
|
133
|
+
when 'Boolean'
|
134
|
+
_attrs[field] ? 1 : 0 unless _attrs[field].nil?
|
114
135
|
else
|
115
136
|
_attrs[field]
|
116
137
|
end
|
@@ -121,31 +142,75 @@ class Yapper::DB
|
|
121
142
|
end
|
122
143
|
end
|
123
144
|
|
124
|
-
|
145
|
+
unless Yapper::Settings.get("#{collection}_idx_defn") == @indexes[collection].to_canonical
|
146
|
+
Yapper::Settings.set("#{collection}_idx_defn", @indexes[collection].to_canonical)
|
147
|
+
configure do|yap|
|
148
|
+
yap.unregisterExtension("#{collection}_IDX") if yap.registeredExtension("#{collection}_IDX")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
index_block = YapDatabaseSecondaryIndex.alloc.initWithSetup(setup, objectBlock: block, version: 1)
|
125
153
|
configure do |yap|
|
126
154
|
yap.registerExtension(index_block, withName: "#{collection}_IDX")
|
127
155
|
end
|
128
156
|
end
|
129
157
|
|
130
|
-
@
|
158
|
+
@index_creation_required = false
|
131
159
|
end
|
132
160
|
end
|
133
161
|
|
134
|
-
def
|
135
|
-
|
136
|
-
@connection
|
162
|
+
def version
|
163
|
+
Yapper::Settings.db_version || 0
|
137
164
|
end
|
138
165
|
|
139
|
-
def
|
140
|
-
|
141
|
-
@db
|
166
|
+
def document_path
|
167
|
+
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] + "/yapper.#{version}.db"
|
142
168
|
end
|
143
169
|
|
144
|
-
|
145
|
-
|
170
|
+
class Transaction
|
171
|
+
attr_accessor :txn
|
172
|
+
|
173
|
+
def initialize(db)
|
174
|
+
@db = db
|
175
|
+
end
|
176
|
+
|
177
|
+
def run(&block)
|
178
|
+
result = nil
|
179
|
+
txn_proc = proc do |_txn|
|
180
|
+
@txn = _txn
|
181
|
+
begin
|
182
|
+
result = block.call(@txn)
|
183
|
+
rescue Exception => e
|
184
|
+
@txn.rollback
|
185
|
+
result = e
|
186
|
+
end
|
187
|
+
end
|
188
|
+
@db.connection.readWriteWithBlock(txn_proc)
|
189
|
+
|
190
|
+
raise result if result.is_a?(Exception)
|
191
|
+
result
|
192
|
+
end
|
146
193
|
end
|
147
194
|
|
148
|
-
|
149
|
-
|
195
|
+
class Notifications
|
196
|
+
def self.track(notifications)
|
197
|
+
Thread.current[:yapper_notifications] ||= {}.with_indifferent_access
|
198
|
+
notifications.each do |namespace, instance|
|
199
|
+
Thread.current[:yapper_notifications][namespace] ||= []
|
200
|
+
Thread.current[:yapper_notifications][namespace] << instance
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.trigger
|
205
|
+
notifications = Thread.current[:yapper_notifications]
|
206
|
+
Thread.current[:yapper_notifications] = nil
|
207
|
+
notifications.each { |namespace, instances| notify(namespace, instances) }
|
208
|
+
end
|
209
|
+
|
210
|
+
private
|
211
|
+
|
212
|
+
def self.notify(namespace, instances)
|
213
|
+
NSNotificationCenter.defaultCenter.postNotificationName("yapper:#{namespace}", object: instances , userInfo: nil)
|
214
|
+
end
|
150
215
|
end
|
151
216
|
end
|
data/lib/yapper/document.rb
CHANGED
@@ -2,19 +2,22 @@ motion_require 'extensions'
|
|
2
2
|
motion_require 'db'
|
3
3
|
|
4
4
|
module Yapper::Document
|
5
|
-
motion_require 'document/attachment'
|
6
5
|
motion_require 'document/callbacks'
|
7
|
-
motion_require 'document/
|
6
|
+
motion_require 'document/persistence'
|
8
7
|
motion_require 'document/relation'
|
9
8
|
motion_require 'document/selection'
|
10
9
|
|
11
10
|
extend MotionSupport::Concern
|
12
11
|
|
13
|
-
include
|
12
|
+
include Persistence
|
14
13
|
include Selection
|
15
14
|
include Callbacks
|
16
15
|
include Relation
|
17
|
-
|
16
|
+
|
17
|
+
included do
|
18
|
+
field :id, :type => String
|
19
|
+
index(:id)
|
20
|
+
end
|
18
21
|
|
19
22
|
module ClassMethods
|
20
23
|
def db
|
@@ -67,7 +67,6 @@ module Yapper::Document
|
|
67
67
|
|
68
68
|
callback_proc = Proc.new do
|
69
69
|
run_callback('after', operation)
|
70
|
-
notify_callback(operation)
|
71
70
|
end
|
72
71
|
|
73
72
|
if Yapper::Document::Callbacks.postponed_callbacks
|
@@ -76,11 +75,5 @@ module Yapper::Document
|
|
76
75
|
callback_proc.call
|
77
76
|
end
|
78
77
|
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def notify_callback(operation)
|
83
|
-
NSNotificationCenter.defaultCenter.postNotificationName("yapper:#{self.model_name}:#{operation}", object: self , userInfo: nil)
|
84
|
-
end
|
85
78
|
end
|
86
79
|
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
module Yapper::Document
|
2
|
-
module
|
2
|
+
module Persistence
|
3
3
|
extend MotionSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
6
|
attr_accessor :attributes
|
7
7
|
attr_accessor :changes
|
8
8
|
attr_accessor :previous_changes
|
9
|
+
attr_reader :destroyed
|
9
10
|
|
10
|
-
|
11
|
-
attr_accessor :fields
|
12
|
-
end
|
11
|
+
class_attribute :fields
|
13
12
|
|
14
13
|
self.fields = {}.with_indifferent_access
|
15
|
-
field :id
|
16
14
|
end
|
17
15
|
|
18
16
|
module ClassMethods
|
@@ -31,19 +29,10 @@ module Yapper::Document
|
|
31
29
|
define_method("#{name}=".to_sym) do |*args, &block|
|
32
30
|
self.set_attribute(name, args[0])
|
33
31
|
end
|
34
|
-
|
35
|
-
if options[:index]
|
36
|
-
index(name, options[:type])
|
37
|
-
end
|
38
32
|
end
|
39
33
|
|
40
|
-
def index(*
|
41
|
-
|
42
|
-
options = self.fields[field]; raise "#{self._type}:#{field} not defined" unless options
|
43
|
-
type = options[:type]; raise "#{self._type}:#{field} must define type as its indexed" if type.nil?
|
44
|
-
|
45
|
-
db.index(self._type, field, type)
|
46
|
-
end
|
34
|
+
def index(*args)
|
35
|
+
db.index(self, args)
|
47
36
|
end
|
48
37
|
|
49
38
|
def indexes
|
@@ -56,10 +45,13 @@ module Yapper::Document
|
|
56
45
|
|
57
46
|
@new_record = options[:new].nil? ? true : options[:new]
|
58
47
|
@changes = {}
|
48
|
+
@queued_saves = []
|
59
49
|
|
60
50
|
assign_attributes({:id => generate_id}, options) if @new_record
|
61
51
|
assign_attributes(attrs, options)
|
62
52
|
|
53
|
+
set_defaults
|
54
|
+
|
63
55
|
self
|
64
56
|
end
|
65
57
|
|
@@ -122,22 +114,27 @@ module Yapper::Document
|
|
122
114
|
end
|
123
115
|
|
124
116
|
def save(options={})
|
125
|
-
db.execute do |txn|
|
117
|
+
db.execute("#{self.model_name}:save" => self) do |txn|
|
118
|
+
@queued_saves.each { |queued, queued_options| queued.save(queued_options) }
|
119
|
+
|
126
120
|
run_callbacks 'save' do
|
127
121
|
txn.setObject(stringify_keys(attributes), forKey: self.id, inCollection: _type)
|
128
122
|
|
129
123
|
@was_new = @new_record
|
130
124
|
@new_record = false
|
125
|
+
@queued_saves = []
|
131
126
|
|
132
127
|
self.previous_changes = self.changes
|
133
128
|
self.changes = {}
|
134
129
|
end
|
135
130
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
131
|
+
unless options[:embedded]
|
132
|
+
# XXX Use middleware pattern instead of this ugliness
|
133
|
+
sync_changes if defined? sync_changes
|
134
|
+
end
|
140
135
|
end
|
136
|
+
|
137
|
+
true
|
141
138
|
end
|
142
139
|
|
143
140
|
def destroy(options={})
|
@@ -150,6 +147,15 @@ module Yapper::Document
|
|
150
147
|
def generate_id
|
151
148
|
BSON::ObjectId.generate
|
152
149
|
end
|
150
|
+
|
151
|
+
def set_defaults
|
152
|
+
self.fields.each do |field, field_options|
|
153
|
+
if __send__(field).nil?
|
154
|
+
default = field_options[:default].respond_to?(:call) ? field_options[:default].call : field_options[:default]
|
155
|
+
set_attribute(field, default)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
153
159
|
end
|
154
160
|
|
155
161
|
private
|
@@ -25,42 +25,49 @@ module Yapper::Document
|
|
25
25
|
raise "All elements in the array must be of the same type" unless docs.all? { |doc| doc.is_a?(docs.first.class) }
|
26
26
|
|
27
27
|
changes = {}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if doc.
|
32
|
-
|
33
|
-
|
28
|
+
db.execute do |txn|
|
29
|
+
docs.each do |doc|
|
30
|
+
if doc.is_a?(Yapper::Document)
|
31
|
+
if doc.persisted?
|
32
|
+
doc.assign_attributes("#{self._type.underscore}" => self)
|
33
|
+
|
34
|
+
if options[:embedded]
|
34
35
|
changes["#{relation.singularize}_ids"] ||= []
|
35
36
|
changes["#{relation.singularize}_ids"] << doc.id
|
36
|
-
|
37
|
-
doc.assign_attributes("#{self._type.underscore}" => self)
|
37
|
+
end
|
38
38
|
|
39
|
+
@queued_saves << [doc, options]
|
40
|
+
else
|
41
|
+
doc.assign_attributes("#{self._type.underscore}" => self)
|
42
|
+
|
43
|
+
if options[:embedded]
|
39
44
|
changes[relation] ||= []
|
40
45
|
changes[relation] << doc.attributes
|
41
|
-
|
42
|
-
doc.save
|
43
46
|
end
|
44
|
-
elsif doc.is_a?(Hash)
|
45
|
-
doc = doc.with_indifferent_access
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
@queued_saves << [doc, options]
|
49
|
+
end
|
50
|
+
elsif doc.is_a?(Hash)
|
51
|
+
doc = doc.with_indifferent_access
|
52
|
+
|
53
|
+
klass = Object.qualified_const_get(relation.singularize.to_s.camelize)
|
54
|
+
instance = klass.find(doc[:id]) if doc[:id]
|
55
|
+
instance ||= klass.new
|
56
|
+
instance.assign_attributes("#{self._type.underscore}" => self)
|
57
|
+
instance.assign_attributes(doc)
|
52
58
|
|
59
|
+
if options[:embedded]
|
53
60
|
changes[relation] ||= []
|
54
61
|
changes[relation] << instance.attributes
|
55
|
-
|
56
|
-
instance.save
|
57
|
-
else
|
58
|
-
raise "Must pass either attributes or an object"
|
59
62
|
end
|
63
|
+
|
64
|
+
@queued_saves << [instance, options]
|
65
|
+
else
|
66
|
+
raise "Must pass either attributes or an object"
|
60
67
|
end
|
61
68
|
end
|
62
|
-
@changes.merge!(changes)
|
63
69
|
end
|
70
|
+
@changes.merge!(changes)
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|