motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Yapper::Timestamps
|
2
|
+
extend MotionSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
field :updated_at, :type => Time
|
6
|
+
field :created_at, :type => Time
|
7
|
+
|
8
|
+
before_save :set_timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_timestamps
|
12
|
+
now = Time.now
|
13
|
+
self.created_at = now if created_at.nil?
|
14
|
+
self.updated_at = now
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe '#all' do
|
2
|
+
before do
|
3
|
+
class SelectionDocument
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field1
|
7
|
+
field :field2
|
8
|
+
end
|
9
|
+
class AnotherSelectionDocument
|
10
|
+
include Yapper::Document
|
11
|
+
|
12
|
+
field :field1
|
13
|
+
field :field2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
before { Yapper::DB.instance.purge }
|
17
|
+
after { Object.send(:remove_const, 'SelectionDocument') }
|
18
|
+
after { Object.send(:remove_const, 'AnotherSelectionDocument') }
|
19
|
+
|
20
|
+
describe 'with no documents created' do
|
21
|
+
it 'returns []' do
|
22
|
+
SelectionDocument.all.should == []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'with a few documents created with string fields' do
|
27
|
+
before do
|
28
|
+
@doc = SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
29
|
+
SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
30
|
+
SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_other_value')
|
31
|
+
SelectionDocument.create(:field1 => 'field1_other_value', :field2 => 'field2_other_value')
|
32
|
+
AnotherSelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns all documents' do
|
36
|
+
SelectionDocument.all.count.should == 4
|
37
|
+
SelectionDocument.all.all? { |doc| doc.class.should == SelectionDocument }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
describe 'callbacks' do
|
2
|
+
before do
|
3
|
+
class CallbackDocument
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field_1
|
7
|
+
field :field_2
|
8
|
+
|
9
|
+
before_save :do_before_save
|
10
|
+
before_save :do_another_before_save
|
11
|
+
after_save :do_after_save
|
12
|
+
after_save :do_another_after_save
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def do_before_save
|
17
|
+
$before_save_1 = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def do_another_before_save
|
21
|
+
$before_save_2 = true
|
22
|
+
end
|
23
|
+
|
24
|
+
def do_after_save
|
25
|
+
$after_save_1 = true
|
26
|
+
end
|
27
|
+
|
28
|
+
def do_another_after_save
|
29
|
+
$after_save_2 = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
before { Yapper::DB.instance.purge }
|
34
|
+
after { Object.send(:remove_const, 'CallbackDocument') }
|
35
|
+
|
36
|
+
describe 'creating documents' do
|
37
|
+
it 'before and after callbacks are fired' do
|
38
|
+
CallbackDocument.create(:field_1 => 'field1',
|
39
|
+
:field_2 => 'field2')
|
40
|
+
|
41
|
+
$before_save_1.should == true
|
42
|
+
$before_save_2.should == true
|
43
|
+
$after_save_1.should == true
|
44
|
+
$after_save_2.should == true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'updating documents' do
|
49
|
+
before do
|
50
|
+
@doc = CallbackDocument.create(:field_1 => 'field1')
|
51
|
+
$before_save_1 = false
|
52
|
+
$before_save_2 = false
|
53
|
+
$after_save_1 = false
|
54
|
+
$after_save_2 = false
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'before and after callbacks are fired' do
|
58
|
+
@doc.field_1 = 'field1_updated'
|
59
|
+
@doc.save
|
60
|
+
|
61
|
+
$before_save_1.should == true
|
62
|
+
$before_save_2.should == true
|
63
|
+
$after_save_1.should == true
|
64
|
+
$after_save_2.should == true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'on failure' do
|
69
|
+
before do
|
70
|
+
class CallbackDocument
|
71
|
+
after_save :fail
|
72
|
+
|
73
|
+
def fail
|
74
|
+
raise "fail"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'rollsback the entire update' do
|
80
|
+
lambda {
|
81
|
+
CallbackDocument.create(:field_1 => 'field1')
|
82
|
+
}.should.raise
|
83
|
+
|
84
|
+
CallbackDocument.all.count.should == 0
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe 'db' do
|
2
|
+
before do
|
3
|
+
class Document
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field_1
|
7
|
+
field :field_2
|
8
|
+
end
|
9
|
+
|
10
|
+
class AnotherDocument
|
11
|
+
include Yapper::Document
|
12
|
+
|
13
|
+
field :field_1
|
14
|
+
field :field_2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
before { Yapper::DB.instance.purge }
|
18
|
+
after { Object.send(:remove_const, 'Document') }
|
19
|
+
after { Object.send(:remove_const, 'AnotherDocument') }
|
20
|
+
|
21
|
+
it 'is thread safe' do
|
22
|
+
threads = []
|
23
|
+
threads << Thread.new { 10.times { Document.create(:field_1 => 'field') } }
|
24
|
+
threads << Thread.new { 10.times { AnotherDocument.create(:field_1 => 'field') } }
|
25
|
+
threads << Thread.new { 10.times { Document.all.each { |d| d.update_attributes(:field_1 => 'bye') } } }
|
26
|
+
threads << Thread.new { 10.times { AnotherDocument.all.each { |d| d.update_attributes(:field_1 => 'bye') } } }
|
27
|
+
threads.each(&:join)
|
28
|
+
|
29
|
+
Document.all.count.should == 10
|
30
|
+
AnotherDocument.all.count.should == 10
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can nest transactions' do
|
34
|
+
Yapper::DB.instance.execute do |txn|
|
35
|
+
Document.create(:field_1 => '1')
|
36
|
+
Document.create(:field_1 => '2')
|
37
|
+
end
|
38
|
+
Document.all.count.should == 2
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
describe '#find' do
|
2
|
+
before do
|
3
|
+
class SelectionDocument
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field1
|
7
|
+
field :field2
|
8
|
+
end
|
9
|
+
class AnotherSelectionDocument
|
10
|
+
include Yapper::Document
|
11
|
+
|
12
|
+
field :field1
|
13
|
+
field :field2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
before { Yapper::DB.instance.purge }
|
17
|
+
after { Object.send(:remove_const, 'SelectionDocument') }
|
18
|
+
after { Object.send(:remove_const, 'AnotherSelectionDocument') }
|
19
|
+
|
20
|
+
describe 'with no documents created' do
|
21
|
+
it 'returns nil when looking up a document' do
|
22
|
+
SelectionDocument.find('xxx').should == nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'with a few documents created with string fields' do
|
27
|
+
before do
|
28
|
+
@doc = SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
29
|
+
SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
30
|
+
SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_other_value')
|
31
|
+
SelectionDocument.create(:field1 => 'field1_other_value', :field2 => 'field2_other_value')
|
32
|
+
AnotherSelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can find a document' do
|
36
|
+
SelectionDocument.find(@doc.id).field1.should == 'field1_value'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'has no changes when selecting a document' do
|
40
|
+
SelectionDocument.find(@doc.id).changes.should == {}
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns nil when looking up a non-existant doc' do
|
44
|
+
SelectionDocument.find('xxx').should == nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns nil when looking up nil' do
|
48
|
+
SelectionDocument.find(nil).should == nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
describe 'Yapper persisting documents' do
|
2
|
+
before do
|
3
|
+
class Document
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field_1
|
7
|
+
field :field_2
|
8
|
+
end
|
9
|
+
end
|
10
|
+
before { Yapper::DB.instance.purge }
|
11
|
+
after { Object.send(:remove_const, 'Document') }
|
12
|
+
|
13
|
+
describe 'creating documents' do
|
14
|
+
it 'supports storing hashes by stringifying keys (to avoid NanoStore bug)' do
|
15
|
+
10.times { Document.create.tap { |doc| doc.update_attributes(:field_1 => { :a => [ { :a => 10 } ] }) } }
|
16
|
+
Document.all.each { |doc| doc.field_1[:b] = 'b'; doc.save }
|
17
|
+
|
18
|
+
Document.all.each { |doc| doc.field_1.should == { 'a' => [ { 'a' => 10 } ], 'b' => 'b' } }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'supports storing Time' do
|
22
|
+
time = Time.now
|
23
|
+
Document.create(:field_1 => time)
|
24
|
+
|
25
|
+
Document.all.first.field_1.should == time
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'tracks changes' do
|
29
|
+
doc = Document.new
|
30
|
+
doc.field_1 = 'field1'
|
31
|
+
doc.field_2 = 'field2'
|
32
|
+
|
33
|
+
doc.changes.should == { 'id' => doc.id,
|
34
|
+
'field_1' => 'field1',
|
35
|
+
'field_2' => 'field2' }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when using #new then #save" do
|
39
|
+
it 'persists the fields' do
|
40
|
+
doc = Document.new
|
41
|
+
doc.field_1 = 'field1'
|
42
|
+
doc.field_2 = 'field2'
|
43
|
+
doc.new_record?.should == true
|
44
|
+
doc.save
|
45
|
+
|
46
|
+
doc = Document.find(doc.id)
|
47
|
+
doc.new_record?.should == false
|
48
|
+
doc.field_1.should == 'field1'
|
49
|
+
doc.field_2.should == 'field2'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when using #create" do
|
54
|
+
it 'persists the fields' do
|
55
|
+
doc = Document.create(:field_1 => 'field1',
|
56
|
+
:field_2 => 'field2')
|
57
|
+
|
58
|
+
doc = Document.find(doc.id)
|
59
|
+
doc.field_1.should == 'field1'
|
60
|
+
doc.field_2.should == 'field2'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'updating documents' do
|
66
|
+
before do
|
67
|
+
@doc = Document.create(:field_1 => 'field1')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'tracks changes' do
|
71
|
+
@doc.field_1 = 'field1_changed'
|
72
|
+
|
73
|
+
@doc.changes.should == { 'field_1' => 'field1_changed' }
|
74
|
+
|
75
|
+
@doc.save
|
76
|
+
|
77
|
+
@doc.changes.should == {}
|
78
|
+
@doc.previous_changes.should == { 'field_1' => 'field1_changed' }
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'saves a false value' do
|
82
|
+
@doc.update_attributes(:field_1 => false)
|
83
|
+
|
84
|
+
@doc.reload.field_1.should == false
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "when updating fields and then #save" do
|
88
|
+
it 'persists the fields' do
|
89
|
+
@doc.field_1 = 'field1_updated'
|
90
|
+
@doc.save
|
91
|
+
|
92
|
+
doc = Document.find(@doc.id)
|
93
|
+
doc.field_1.should == 'field1_updated'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "when using #update_attributes" do
|
98
|
+
it 'persists the fields' do
|
99
|
+
@doc.update_attributes(:field_1 => 'field1_updated')
|
100
|
+
|
101
|
+
doc = Document.find(@doc.id)
|
102
|
+
doc.field_1.should == 'field1_updated'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'destroying documents' do
|
108
|
+
before do
|
109
|
+
@doc = Document.create(:field_1 => 'field1')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'destroys the document' do
|
113
|
+
@doc.destroy
|
114
|
+
|
115
|
+
Document.find(@doc.id).should == nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
describe 'Yapper document 1:N relationship' do
|
2
|
+
before do
|
3
|
+
class ParentDocument
|
4
|
+
include Yapper::Document
|
5
|
+
|
6
|
+
field :field_1
|
7
|
+
|
8
|
+
has_many :child_documents
|
9
|
+
end
|
10
|
+
class ChildDocument
|
11
|
+
include Yapper::Document
|
12
|
+
|
13
|
+
field :field_1
|
14
|
+
field :field_2
|
15
|
+
|
16
|
+
belongs_to :parent_document
|
17
|
+
end
|
18
|
+
end
|
19
|
+
before { Yapper::DB.instance.purge }
|
20
|
+
after { ['ParentDocument', 'ChildDocument'].each { |klass| Object.send(:remove_const, klass) } }
|
21
|
+
|
22
|
+
it 'can accept nested attributes' do
|
23
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
24
|
+
:child_documents => [
|
25
|
+
{ :field_1 => 'child0' },
|
26
|
+
{ :field_1 => 'child1' }
|
27
|
+
])
|
28
|
+
|
29
|
+
@parent.field_1.should == 'parent'
|
30
|
+
@parent.child_documents.collect(&:field_1).should == ['child0', 'child1']
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can accept an nested attributes with ids' do
|
34
|
+
children = 2.times.map { |i| { :id => BSON::ObjectId.generate, :field_1 => "child#{i}" } }
|
35
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
36
|
+
:child_documents => children)
|
37
|
+
|
38
|
+
children.each do |child|
|
39
|
+
ChildDocument.find(child[:id]).should.not == nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can accept array of initialized children' do
|
44
|
+
children = 2.times.map { |i| ChildDocument.new(:field_1 => "child#{i}") }
|
45
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
46
|
+
:child_documents => children)
|
47
|
+
|
48
|
+
@parent.field_1.should == 'parent'
|
49
|
+
@parent.child_documents.collect(&:field_1).should == ['child0', 'child1']
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can accept array of created children' do
|
53
|
+
children = 2.times.map { |i| ChildDocument.create(:field_1 => "child#{i}") }
|
54
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
55
|
+
:child_documents => children)
|
56
|
+
|
57
|
+
@parent.field_1.should == 'parent'
|
58
|
+
@parent.child_documents.collect(&:field_1).should == ['child0', 'child1']
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'can update a child document via nested attributes' do
|
62
|
+
children = 2.times.map { |i| { :id => BSON::ObjectId.generate,
|
63
|
+
:field_1 => "child#{i}",
|
64
|
+
:field_2 => 'value' } }
|
65
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
66
|
+
:child_documents => children)
|
67
|
+
@parent.update_attributes(:child_documents => [{ :id => children[0][:id],
|
68
|
+
:field_1 => 'updated0' },
|
69
|
+
{ :id => children[1][:id],
|
70
|
+
:field_1 => 'updated1' }])
|
71
|
+
|
72
|
+
children.each_with_index do |child, i|
|
73
|
+
ChildDocument.find(child[:id]).field_1.should == "updated#{i}"
|
74
|
+
ChildDocument.find(child[:id]).field_2.should == "value"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'can set a parent to nil' do
|
79
|
+
child = ChildDocument.create(:field_1 => 'child_field',
|
80
|
+
:parent_document => nil)
|
81
|
+
|
82
|
+
child.field_1.should == 'child_field'
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'with a parent with many children' do
|
86
|
+
before do
|
87
|
+
@parent = ParentDocument.create(:field_1 => 'parent')
|
88
|
+
3.times { ChildDocument.create(:parent_document => @parent) }
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'the child can access the parent' do
|
92
|
+
@parent.reload
|
93
|
+
|
94
|
+
@parent.child_documents.count.should == 3
|
95
|
+
@parent.child_documents.each { |doc| doc.class.should == ChildDocument }
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'the parent can access the child' do
|
99
|
+
ChildDocument.all.each { |doc| doc.parent_document.id.should == @parent.id }
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'when a child is destroyed' do
|
103
|
+
before do
|
104
|
+
@last_id = ChildDocument.all.last.id
|
105
|
+
ChildDocument.all.last.destroy
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'the child is removed from the parent' do
|
109
|
+
@parent.reload
|
110
|
+
|
111
|
+
@parent.child_documents.count.should == 2
|
112
|
+
@parent.child_documents.collect(&:id).each { |id| id.should.not == @last_id }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'with a before_save callback on the child that references the parent document' do
|
118
|
+
before do
|
119
|
+
ChildDocument.class_eval do
|
120
|
+
before_save :set_field_2
|
121
|
+
|
122
|
+
def set_field_2
|
123
|
+
self.field_2 = self.parent_document.id
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'includes parent relation in the callback' do
|
129
|
+
@parent = ParentDocument.create(:field_1 => 'parent',
|
130
|
+
:child_documents => [{ :field_1 => "value" }])
|
131
|
+
|
132
|
+
@parent.child_documents.first.field_2.should == @parent.id
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'Yapper document 1:N:1 relationship' do
|
138
|
+
before do
|
139
|
+
class Parent1
|
140
|
+
include Yapper::Document
|
141
|
+
|
142
|
+
field :field_1
|
143
|
+
|
144
|
+
has_many :child_documents
|
145
|
+
end
|
146
|
+
class Parent2
|
147
|
+
include Yapper::Document
|
148
|
+
|
149
|
+
field :field_1
|
150
|
+
|
151
|
+
has_many :child_documents
|
152
|
+
end
|
153
|
+
class ChildDocument
|
154
|
+
include Yapper::Document
|
155
|
+
|
156
|
+
field :field_1
|
157
|
+
|
158
|
+
belongs_to :parent1
|
159
|
+
belongs_to :parent2
|
160
|
+
end
|
161
|
+
end
|
162
|
+
after { Yapper::DB.instance.purge }
|
163
|
+
after { ['Parent1', 'Parent2', 'ChildDocument'].each { |klass| Object.send(:remove_const, klass) } }
|
164
|
+
|
165
|
+
it 'can create child with many parents' do
|
166
|
+
parent1 = Parent1.create(:field_1 => 'parent1')
|
167
|
+
parent2 = Parent2.create(:field_1 => 'parent2')
|
168
|
+
|
169
|
+
child = ChildDocument.create(:parent1 => parent1, :parent2 => parent2)
|
170
|
+
|
171
|
+
child.parent1.field_1.should == 'parent1'
|
172
|
+
child.parent2.field_1.should == 'parent2'
|
173
|
+
end
|
174
|
+
end
|