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.
Files changed (296) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/lib/motion-yapper.rb +1 -0
  8. data/lib/yapper.rb +3 -5
  9. data/lib/yapper/config.rb +2 -0
  10. data/lib/yapper/db.rb +105 -40
  11. data/lib/yapper/document.rb +7 -4
  12. data/lib/yapper/document/callbacks.rb +0 -7
  13. data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
  14. data/lib/yapper/document/relation.rb +29 -22
  15. data/lib/yapper/document/selection.rb +122 -54
  16. data/lib/yapper/extensions.rb +12 -24
  17. data/lib/yapper/settings.rb +43 -0
  18. data/lib/yapper/timestamps.rb +2 -0
  19. data/lib/yapper/version.rb +1 -1
  20. data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
  21. data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
  22. data/spec/integration/db_spec.rb +70 -0
  23. data/spec/integration/defaults_spec.rb +37 -0
  24. data/spec/integration/extensions_spec.rb +14 -0
  25. data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
  26. data/spec/integration/relation_spec.rb +4 -4
  27. data/vendor/Podfile.lock +9 -11
  28. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  29. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  30. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  31. data/vendor/Pods/.build/libPods.a +0 -0
  32. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
  33. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  34. data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
  35. data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  36. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
  37. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
  38. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
  39. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
  40. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
  41. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
  74. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
  75. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
  76. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
  77. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
  78. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
  79. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
  80. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
  81. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
  82. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
  83. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
  84. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
  85. data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
  86. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
  87. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  88. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
  89. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
  90. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
  92. data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
  93. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
  94. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  95. data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
  96. data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  97. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
  98. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
  99. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
  100. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
  101. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
  102. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
  103. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
  104. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
  105. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
  106. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  107. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  108. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
  109. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  110. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  111. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  112. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  113. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  114. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  115. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
  116. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
  117. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
  118. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
  119. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
  120. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
  123. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
  124. data/vendor/Pods/Headers/____Pods-environment.h +15 -15
  125. data/vendor/Pods/Manifest.lock +9 -11
  126. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
  127. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
  128. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
  129. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
  130. data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
  131. data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
  132. data/vendor/Pods/Pods-environment.h +15 -15
  133. data/vendor/Pods/Pods.xcconfig +3 -3
  134. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
  135. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
  136. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
  137. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
  138. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
  139. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  140. data/vendor/Pods/YapDatabase/README.md +3 -1
  141. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
  142. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
  143. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
  144. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
  145. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
  146. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
  147. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
  148. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
  149. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
  150. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
  151. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
  152. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
  153. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
  154. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
  155. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
  156. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
  157. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
  158. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
  159. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
  160. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
  161. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
  162. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
  163. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
  164. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
  165. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
  166. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
  167. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
  168. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  169. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
  170. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
  171. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
  172. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
  173. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
  174. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
  175. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
  176. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
  177. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
  178. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
  179. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
  180. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
  181. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
  182. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
  183. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
  184. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
  185. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
  186. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
  187. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
  188. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
  189. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
  190. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
  191. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
  192. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
  193. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
  194. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
  195. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
  196. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
  197. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
  198. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
  199. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
  200. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
  201. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
  202. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
  203. data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
  204. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  205. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
  206. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
  207. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
  208. metadata +80 -108
  209. data/Gemfile.lock +0 -63
  210. data/lib/yapper/attachment.rb +0 -48
  211. data/lib/yapper/document/attachment.rb +0 -26
  212. data/lib/yapper/sync.rb +0 -134
  213. data/lib/yapper/sync/data.rb +0 -12
  214. data/lib/yapper/sync/event.rb +0 -194
  215. data/lib/yapper/sync/queue.rb +0 -164
  216. data/spec/integration/all_spec.rb +0 -40
  217. data/spec/integration/sync_spec.rb +0 -42
  218. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
  219. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
  220. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  221. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
  222. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
  223. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
  224. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  225. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
  226. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  227. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
  228. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
  229. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  230. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
  231. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
  232. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
  233. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  234. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
  235. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  236. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
  237. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  238. data/vendor/Pods/AFNetworking/README.md +0 -208
  239. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
  240. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  241. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
  242. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  243. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  244. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
  245. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  246. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
  247. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  248. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  249. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
  250. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
  251. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
  252. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  253. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
  254. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  255. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  256. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
  257. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  258. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
  259. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  260. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  261. data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
  262. data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
  263. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
  265. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
  266. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
  267. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
  268. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
  269. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
  271. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
  272. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
  274. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  275. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  276. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
  277. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  278. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
  279. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  280. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
  281. data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
  282. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
  283. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
  284. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
  285. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
  286. data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
  287. data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
  288. data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
  289. data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
  290. data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
  291. data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
  292. data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
  293. data/vendor/Pods/Reachability/LICENCE.txt +0 -24
  294. data/vendor/Pods/Reachability/README.md +0 -65
  295. data/vendor/Pods/Reachability/Reachability.h +0 -109
  296. data/vendor/Pods/Reachability/Reachability.m +0 -527
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3220185888e67be062af7600cb81346cdb6af641
4
- data.tar.gz: 9484efc4e0bc1ac6b2f2da5c271bc7d7bd2849b2
3
+ metadata.gz: 7395ef1251cdd8864f3acb18c0a151766fd10835
4
+ data.tar.gz: 121948cad3cc4af4fa4e4ae0b8d6e979610eb645
5
5
  SHA512:
6
- metadata.gz: 4db43401b1dbe80f9b8700a4f3ac0fbcf48431f6945920bd0e9d67c5b6206409464572af6b8ebbdcfe816fabb8f6479a96a50ec3e643cd1af1e5c5d5cdd79216
7
- data.tar.gz: 2f48add1d5a952009a13a6df7e2bd5ee1890a3f0f73a74bfd14b5cdb41b1e6ef141ffc1683751943021a0b471f4b6a90f54165dfdff16a9c5bb6467c11cdcfac
6
+ metadata.gz: 6675d2d18eaef05d80678a3f22edc55ac5d4a908ee9b66c621ea31c9a7a4bd1048a0b02dd69e95ad7c02d064e0d6d97f57b4ec45e84d0fe99f12a166f302891b
7
+ data.tar.gz: a174b03c1edbb8ae5099e571ce9e8595e9fc2044384f176071777aeb911d4afcda3a7fc3f9d3dbb16a868a83cad22cd48c1c7d07645230024efda2d7c56662a0
data/.gitignore CHANGED
@@ -14,7 +14,7 @@ resources/*.momd
14
14
  resources/*.nib
15
15
  resources/*.storyboardc
16
16
  tags
17
- vendor/*/.build
18
- vendor/*/build-*
19
17
  .ruby-version
20
18
  .ruby-gemset
19
+ Gemfile.lock
20
+ vendor/YapDatabaseRubyMotion/build*
@@ -1,6 +1,8 @@
1
1
  language: objective-c
2
2
  before_install:
3
3
  - (ruby --version)
4
+ - mkdir -p ~/Library/RubyMotion/build
5
+ - sudo motion update
4
6
  install:
5
7
  - bundle
6
8
  script: bundle exec rake spec
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in gemspec
4
4
  gem 'rake'
5
+ gem 'bubble-wrap'
5
6
  gemspec
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/nanoid)
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
@@ -4,7 +4,7 @@ require 'motion/project/template/ios'
4
4
  require 'motion-cocoapods'
5
5
  require 'motion-logger'
6
6
  require 'motion-redgreen'
7
- require 'webstub'
7
+ require 'bubble-wrap/core'
8
8
  require 'yapper'
9
9
 
10
10
  Motion::Project::App.setup do |app|
@@ -0,0 +1 @@
1
+ require 'yapper'
@@ -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.3'
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 => '-I../Pods/Headers -fobjc-arc',
28
- :cflags => '-I../Pods/Headers -fobjc-arc')
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
@@ -1,3 +1,5 @@
1
+ motion_require 'yapper'
2
+
1
3
  module Yapper::Config
2
4
  COLLECTION = '_config'
3
5
  extend self
@@ -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
- exception = nil; result = nil
40
- unless self.txn
41
- txn_proc = proc do |_txn|
42
- self.txn = _txn
43
- begin
44
- result = block.call(txn)
45
- rescue Exception => e
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
- connection.readWriteWithBlock(txn_proc)
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
- create_indexes!(true)
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 txn=(txn)
68
- Thread.current[:yapper_txn] = txn
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 txn
72
- Thread.current[:yapper_txn]
86
+ def connection
87
+ Dispatch.once { @connection ||= db.newConnection }
88
+ @connection
73
89
  end
74
90
 
75
- def index(collection, field, type)
76
- @indexes[collection] ||= {}
77
- @indexes[collection][field] = { :type => type }
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!(force=false)
83
- return if @indexes_created && !force
99
+ def create_indexes!
100
+ return unless @index_creation_required
84
101
 
85
102
  @@queue.sync do
86
- return if @indexes_created && !force
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
- index_block = YapDatabaseSecondaryIndex.alloc.initWithSetup(setup, objectBlock: block)
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
- @indexes_created = true
158
+ @index_creation_required = false
131
159
  end
132
160
  end
133
161
 
134
- def connection
135
- Dispatch.once { @connection ||= db.newConnection }
136
- @connection
162
+ def version
163
+ Yapper::Settings.db_version || 0
137
164
  end
138
165
 
139
- def db
140
- Dispatch.once { @db ||= YapDatabase.alloc.initWithPath(document_path) }
141
- @db
166
+ def document_path
167
+ NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] + "/yapper.#{version}.db"
142
168
  end
143
169
 
144
- def version
145
- Yapper::Config.db_version || 0
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
- def document_path
149
- NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] + "/yapper.#{version}.db"
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
@@ -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/persistance'
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 Persistance
12
+ include Persistence
14
13
  include Selection
15
14
  include Callbacks
16
15
  include Relation
17
- include Attachment
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 Persistance
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
- class << self
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(*index_fields)
41
- index_fields.each do |field|
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
- # XXX Use middleware pattern instead of this ugliness
137
- sync_changes if defined? sync_changes
138
-
139
- true
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
- Yapper::Sync.disabled do
29
- db.execute do |txn|
30
- docs.each do |doc|
31
- if doc.is_a?(Yapper::Document)
32
- if doc.persisted?
33
- doc.update_attributes("#{self._type.underscore}" => self)
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
- else
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
- klass = Object.qualified_const_get(relation.singularize.to_s.camelize)
48
- instance = klass.find(doc[:id]) if doc[:id]
49
- instance ||= klass.new
50
- instance.assign_attributes("#{self._type.underscore}" => self)
51
- instance.assign_attributes(doc)
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