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
@@ -7,10 +7,20 @@
7
7
  #import "YapDatabaseSecondaryIndexTransaction.h"
8
8
 
9
9
  #import "YapDatabaseSecondaryIndexSetup.h"
10
+ #import "YapDatabaseSecondaryIndexSetupPrivate.h"
11
+
10
12
  #import "YapCache.h"
11
13
 
12
14
  #import "sqlite3.h"
13
15
 
16
+ /**
17
+ * This version number is stored in the yap2 table.
18
+ * If there is a major re-write to this class, then the version number will be incremented,
19
+ * and the class can automatically rebuild the table as needed.
20
+ **/
21
+ #define YAP_DATABASE_SECONDARY_INDEX_CLASS_VERSION 1
22
+
23
+
14
24
  @interface YapDatabaseSecondaryIndex () {
15
25
  @public
16
26
 
@@ -0,0 +1,18 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "YapDatabaseSecondaryIndexSetup.h"
3
+
4
+
5
+ @interface YapDatabaseSecondaryIndexSetup ()
6
+
7
+ /**
8
+ * This method compares its setup to a current table structure.
9
+ *
10
+ * @param columns
11
+ *
12
+ * Dictionary of column names and affinity.
13
+ *
14
+ * @see YapDatabase columnNamesAndAffinityForTable:using:
15
+ **/
16
+ - (BOOL)matchesExistingColumnNamesAndAffinity:(NSDictionary *)columns;
17
+
18
+ @end
@@ -97,4 +97,53 @@ typedef enum {
97
97
  block:(YapDatabaseSecondaryIndexBlock)block
98
98
  blockType:(YapDatabaseSecondaryIndexBlockType)blockType;
99
99
 
100
+ /**
101
+ * Creates a new secondary index extension.
102
+ * After creation, you'll need to register the extension with the database system.
103
+ *
104
+ * @param setup
105
+ *
106
+ * A YapDatabaseSecondaryIndexSetup instance allows you to specify the column names and type.
107
+ * The column names can be whatever you want, with a few exceptions for reserved names such as "rowid".
108
+ * The types can reflect numbers or text.
109
+ *
110
+ * @param block
111
+ *
112
+ * Pass a block that is one of the following types:
113
+ * - YapDatabaseSecondaryIndexWithKeyBlock
114
+ * - YapDatabaseSecondaryIndexWithObjectBlock
115
+ * - YapDatabaseSecondaryIndexWithMetadataBlock
116
+ * - YapDatabaseSecondaryIndexWithRowBlock
117
+ *
118
+ * @param blockType
119
+ *
120
+ * Pass the blockType enum that matches the passed block:
121
+ * - YapDatabaseSecondaryIndexBlockTypeWithKey
122
+ * - YapDatabaseSecondaryIndexBlockTypeWithObject
123
+ * - YapDatabaseSecondaryIndexBlockTypeWithMetadata
124
+ * - YapDatabaseSecondaryIndexBlockTypeWithRow
125
+ *
126
+ * @param version
127
+ *
128
+ * If, after creating the secondary index(es), you need to change the setup or block,
129
+ * then simply increment the version parameter. If you pass a version that is different from the last
130
+ * initialization of the extension, then it will automatically re-create itself.
131
+ *
132
+ * @see YapDatabaseSecondaryIndexSetup
133
+ * @see YapDatabase registerExtension:withName:
134
+ **/
135
+ - (id)initWithSetup:(YapDatabaseSecondaryIndexSetup *)setup
136
+ block:(YapDatabaseSecondaryIndexBlock)block
137
+ blockType:(YapDatabaseSecondaryIndexBlockType)blockType
138
+ version:(int)version;
139
+
140
+ /**
141
+ * The version assists in making changes to the extension.
142
+ *
143
+ * If you need to change the columnNames and/or block,
144
+ * then simply pass an incremented version during the init method,
145
+ * and the FTS extension will automatically update itself.
146
+ **/
147
+ @property (nonatomic, assign, readonly) int version;
148
+
100
149
  @end
@@ -53,6 +53,8 @@
53
53
  #pragma mark Instance
54
54
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55
55
 
56
+ @synthesize version = version;
57
+
56
58
  - (id)init
57
59
  {
58
60
  NSAssert(NO, @"Must use designated initializer");
@@ -62,6 +64,14 @@
62
64
  - (id)initWithSetup:(YapDatabaseSecondaryIndexSetup *)inSetup
63
65
  block:(YapDatabaseSecondaryIndexBlock)inBlock
64
66
  blockType:(YapDatabaseSecondaryIndexBlockType)inBlockType
67
+ {
68
+ return [self initWithSetup:inSetup block:inBlock blockType:inBlockType version:0];
69
+ }
70
+
71
+ - (id)initWithSetup:(YapDatabaseSecondaryIndexSetup *)inSetup
72
+ block:(YapDatabaseSecondaryIndexBlock)inBlock
73
+ blockType:(YapDatabaseSecondaryIndexBlockType)inBlockType
74
+ version:(int)inVersion
65
75
  {
66
76
  // Sanity checks
67
77
 
@@ -110,6 +120,8 @@
110
120
  blockType = inBlockType;
111
121
 
112
122
  columnNamesSharedKeySet = [NSDictionary sharedKeySetForKeys:[setup columnNames]];
123
+
124
+ version = inVersion;
113
125
  }
114
126
  return self;
115
127
  }
@@ -47,7 +47,11 @@ static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
47
47
  - (void)dealloc
48
48
  {
49
49
  [queryCache removeAllObjects];
50
-
50
+ [self _flushStatements];
51
+ }
52
+
53
+ - (void)_flushStatements
54
+ {
51
55
  sqlite_finalize_null(&insertStatement);
52
56
  sqlite_finalize_null(&updateStatement);
53
57
  sqlite_finalize_null(&removeStatement);
@@ -57,19 +61,16 @@ static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
57
61
  /**
58
62
  * Required override method from YapDatabaseExtensionConnection
59
63
  **/
60
- - (void)_flushMemoryWithLevel:(int)level
64
+ - (void)_flushMemoryWithFlags:(YapDatabaseConnectionFlushMemoryFlags)flags
61
65
  {
62
- if (level >= YapDatabaseConnectionFlushMemoryLevelMild)
66
+ if (flags & YapDatabaseConnectionFlushMemoryFlags_Caches)
63
67
  {
64
68
  [queryCache removeAllObjects];
65
69
  }
66
70
 
67
- if (level >= YapDatabaseConnectionFlushMemoryLevelModerate)
71
+ if (flags & YapDatabaseConnectionFlushMemoryFlags_Statements)
68
72
  {
69
- sqlite_finalize_null(&insertStatement);
70
- sqlite_finalize_null(&updateStatement);
71
- sqlite_finalize_null(&removeStatement);
72
- sqlite_finalize_null(&removeAllStatement);
73
+ [self _flushStatements];
73
74
  }
74
75
  }
75
76
 
@@ -130,7 +130,10 @@
130
130
 
131
131
  - (YapDatabaseSecondaryIndexColumn *)columnAtIndex:(NSUInteger)index
132
132
  {
133
- return [setup objectAtIndex:index];
133
+ if (index < [setup count])
134
+ return [setup objectAtIndex:index];
135
+ else
136
+ return nil;
134
137
  }
135
138
 
136
139
  - (NSArray *)columnNames
@@ -160,6 +163,49 @@
160
163
  return [setup countByEnumeratingWithState:state objects:buffer count:length];
161
164
  }
162
165
 
166
+ /**
167
+ * The columns parameter comes from:
168
+ * [YapDatabase columnNamesAndAffinityForTable:using:]
169
+ **/
170
+ - (BOOL)matchesExistingColumnNamesAndAffinity:(NSDictionary *)columns
171
+ {
172
+ // The columns parameter will include the 'rowid' column, which we need to ignore.
173
+
174
+ if (([setup count] + 1) != [columns count])
175
+ {
176
+ return NO;
177
+ }
178
+
179
+ for (YapDatabaseSecondaryIndexColumn *setupColumn in setup)
180
+ {
181
+ NSString *existingAffinity = [columns objectForKey:setupColumn.name];
182
+ if (existingAffinity == nil)
183
+ {
184
+ return NO;
185
+ }
186
+ else
187
+ {
188
+ if (setupColumn.type == YapDatabaseSecondaryIndexTypeInteger)
189
+ {
190
+ if ([existingAffinity caseInsensitiveCompare:@"INTEGER"] != NSOrderedSame)
191
+ return NO;
192
+ }
193
+ else if (setupColumn.type == YapDatabaseSecondaryIndexTypeReal)
194
+ {
195
+ if ([existingAffinity caseInsensitiveCompare:@"REAL"] != NSOrderedSame)
196
+ return NO;
197
+ }
198
+ else if (setupColumn.type == YapDatabaseSecondaryIndexTypeText)
199
+ {
200
+ if ([existingAffinity caseInsensitiveCompare:@"TEXT"] != NSOrderedSame)
201
+ return NO;
202
+ }
203
+ }
204
+ }
205
+
206
+ return YES;
207
+ }
208
+
163
209
  @end
164
210
 
165
211
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -181,4 +227,19 @@
181
227
  return self;
182
228
  }
183
229
 
230
+ - (NSString *)description
231
+ {
232
+ NSString *typeStr;
233
+ if (type == YapDatabaseSecondaryIndexTypeInteger)
234
+ typeStr = @"Integer";
235
+ else if (type == YapDatabaseSecondaryIndexTypeReal)
236
+ typeStr = @"Real";
237
+ else if (type == YapDatabaseSecondaryIndexTypeText)
238
+ typeStr = @"Text";
239
+ else
240
+ typeStr = @"Unknown";
241
+
242
+ return [NSString stringWithFormat:@"<YapDatabaseSecondaryIndexColumn: name(%@), type(%@)>", name, typeStr];
243
+ }
244
+
184
245
  @end
@@ -22,11 +22,11 @@
22
22
  #endif
23
23
 
24
24
  /**
25
- * This version number is stored in the yap2 table.
26
- * If there is a major re-write to this class, then the version number will be incremented,
27
- * and the class can automatically rebuild the tables as needed.
25
+ * Declare that this class implements YapDatabaseExtensionTransaction_Hooks protocol.
26
+ * This is done privately, as the protocol is internal.
28
27
  **/
29
- #define YAP_DATABASE_SECONDARY_INDEX_CLASS_VERSION 1
28
+ @interface YapDatabaseSecondaryIndexTransaction () <YapDatabaseExtensionTransaction_Hooks>
29
+ @end
30
30
 
31
31
 
32
32
  @implementation YapDatabaseSecondaryIndexTransaction
@@ -54,14 +54,17 @@
54
54
  **/
55
55
  - (BOOL)createIfNeeded
56
56
  {
57
- int oldClassVersion = [self intValueForExtensionKey:@"classVersion"];
57
+ int oldClassVersion = 0;
58
+ BOOL hasOldClassVersion = [self getIntValue:&oldClassVersion forExtensionKey:@"classVersion"];
58
59
  int classVersion = YAP_DATABASE_SECONDARY_INDEX_CLASS_VERSION;
59
60
 
60
61
  if (oldClassVersion != classVersion)
61
62
  {
62
- // First time registration
63
+ // First time registration (or at least for this version)
63
64
 
64
- [self upgradeFromForOldClassVersion:oldClassVersion];
65
+ if (hasOldClassVersion) {
66
+ if (![self dropTable]) return NO;
67
+ }
65
68
 
66
69
  if (![self createTable]) return NO;
67
70
  if (![self populate]) return NO;
@@ -87,6 +90,53 @@
87
90
 
88
91
  [self setIntValue:newVersion forExtensionKey:@"version"];
89
92
  }
93
+
94
+ // The following code is designed to assist developers in understanding extension changes.
95
+ // The rules are straight-forward and easy to remember:
96
+ //
97
+ // - If you make ANY changes to the configuration of the extension then you MUST change the version.
98
+ //
99
+ // For this extension, that means you MUST change the version if ANY of the following are true:
100
+ //
101
+ // - you changed the setup
102
+ // - you changed the block in any meaningful way (which would result in different values for any existing row)
103
+ //
104
+ // Note: The code below detects only changes to the setup.
105
+ // It could theoretically handle such changes, and automatically force a repopulation.
106
+ // This is a bad idea for two reasons:
107
+ //
108
+ // - First, it complicates the rules. The rules, as stated above, are simple. They follow the KISS principle.
109
+ // Changing these rules would pose a complication that increases cognitive overhead.
110
+ // It may be easy to remember now, but 6 months from now the nuance has become hazy.
111
+ // Additionally, the rest of the database system follows the same set of rules.
112
+ // So adding a complication for just a particular extension is even more confusing.
113
+ //
114
+ // - Second, it adds overhead to the registration process.
115
+ // This sanity check doesn't come for free.
116
+ // And the overhead is only helpful during the development lifecycle.
117
+ // It's certainly not something you want in a shipped version.
118
+ //
119
+ #if DEBUG
120
+ else
121
+ {
122
+ __unsafe_unretained YapDatabase *database = databaseTransaction->connection->database;
123
+ sqlite3 *db = databaseTransaction->connection->db;
124
+
125
+ NSDictionary *columns = [database columnNamesAndAffinityForTable:[self tableName] using:db];
126
+
127
+ YapDatabaseSecondaryIndexSetup *setup = secondaryIndexConnection->secondaryIndex->setup;
128
+
129
+ if (![setup matchesExistingColumnNamesAndAffinity:columns])
130
+ {
131
+ YDBLogError(@"Error creating secondary index extension (%@):"
132
+ @" The given setup doesn't match the previously registered setup."
133
+ @" If you change the setup, or you change the block in any meaningful way,"
134
+ @" then you MUST change the version as well.",
135
+ THIS_METHOD);
136
+ return NO;
137
+ }
138
+ }
139
+ #endif
90
140
  }
91
141
 
92
142
  return YES;
@@ -108,16 +158,6 @@
108
158
  return YES;
109
159
  }
110
160
 
111
- /**
112
- * Internal method.
113
- *
114
- * This method is used to handle the upgrade process from earlier architectures of this class.
115
- **/
116
- - (void)upgradeFromForOldClassVersion:(int)oldClassVersion
117
- {
118
- // Reserved for future use...
119
- }
120
-
121
161
  /**
122
162
  * Internal method.
123
163
  *
@@ -591,8 +631,7 @@
591
631
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
592
632
  **/
593
633
  - (void)handleInsertObject:(id)object
594
- forKey:(NSString *)key
595
- inCollection:(NSString *)collection
634
+ forCollectionKey:(YapCollectionKey *)collectionKey
596
635
  withMetadata:(id)metadata
597
636
  rowid:(int64_t)rowid
598
637
  {
@@ -600,6 +639,9 @@
600
639
 
601
640
  __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
602
641
 
642
+ __unsafe_unretained NSString *collection = collectionKey.collection;
643
+ __unsafe_unretained NSString *key = collectionKey.key;
644
+
603
645
  // Invoke the block to find out if the object should be included in the index.
604
646
 
605
647
  if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey)
@@ -650,8 +692,7 @@
650
692
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
651
693
  **/
652
694
  - (void)handleUpdateObject:(id)object
653
- forKey:(NSString *)key
654
- inCollection:(NSString *)collection
695
+ forCollectionKey:(YapCollectionKey *)collectionKey
655
696
  withMetadata:(id)metadata
656
697
  rowid:(int64_t)rowid
657
698
  {
@@ -659,6 +700,9 @@
659
700
 
660
701
  __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
661
702
 
703
+ __unsafe_unretained NSString *collection = collectionKey.collection;
704
+ __unsafe_unretained NSString *key = collectionKey.key;
705
+
662
706
  // Invoke the block to find out if the object should be included in the index.
663
707
 
664
708
  if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey)
@@ -711,15 +755,79 @@
711
755
  * YapDatabase extension hook.
712
756
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
713
757
  **/
714
- - (void)handleUpdateMetadata:(id)metadata
715
- forKey:(NSString *)key
716
- inCollection:(NSString *)collection
717
- withRowid:(int64_t)rowid
758
+ - (void)handleReplaceObject:(id)object forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
718
759
  {
719
760
  YDBLogAutoTrace();
720
761
 
721
762
  __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
722
763
 
764
+ __unsafe_unretained NSString *collection = collectionKey.collection;
765
+ __unsafe_unretained NSString *key = collectionKey.key;
766
+
767
+ // Invoke the block to find out if the object should be included in the index.
768
+
769
+ id metadata = nil;
770
+
771
+ if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithKey ||
772
+ secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithMetadata)
773
+ {
774
+ // Index values are based on the key or object.
775
+ // Neither have changed, and thus the values haven't changed.
776
+
777
+ return;
778
+ }
779
+ else
780
+ {
781
+ // Index values are based on object or row (object+metadata).
782
+ // Invoke block to see what the new values are.
783
+
784
+ if (secondaryIndex->blockType == YapDatabaseSecondaryIndexBlockTypeWithObject)
785
+ {
786
+ __unsafe_unretained YapDatabaseSecondaryIndexWithObjectBlock block =
787
+ (YapDatabaseSecondaryIndexWithObjectBlock)secondaryIndex->block;
788
+
789
+ block(secondaryIndexConnection->blockDict, collection, key, object);
790
+ }
791
+ else
792
+ {
793
+ __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
794
+ (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
795
+
796
+ metadata = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
797
+ block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
798
+ }
799
+
800
+ if ([secondaryIndexConnection->blockDict count] == 0)
801
+ {
802
+ // Remove associated values from index (if needed).
803
+ // This was an update operation, so the rowid may have previously had values in the index.
804
+
805
+ [self removeRowid:rowid];
806
+ }
807
+ else
808
+ {
809
+ // Add values to index (or update them).
810
+ // This was an update operation, so we need to insert or update.
811
+
812
+ [self addRowid:rowid isNew:NO];
813
+ [secondaryIndexConnection->blockDict removeAllObjects];
814
+ }
815
+ }
816
+ }
817
+
818
+ /**
819
+ * YapDatabase extension hook.
820
+ * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
821
+ **/
822
+ - (void)handleReplaceMetadata:(id)metadata forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
823
+ {
824
+ YDBLogAutoTrace();
825
+
826
+ __unsafe_unretained YapDatabaseSecondaryIndex *secondaryIndex = secondaryIndexConnection->secondaryIndex;
827
+
828
+ __unsafe_unretained NSString *collection = collectionKey.collection;
829
+ __unsafe_unretained NSString *key = collectionKey.key;
830
+
723
831
  // Invoke the block to find out if the object should be included in the index.
724
832
 
725
833
  id object = nil;
@@ -749,7 +857,7 @@
749
857
  __unsafe_unretained YapDatabaseSecondaryIndexWithRowBlock block =
750
858
  (YapDatabaseSecondaryIndexWithRowBlock)secondaryIndex->block;
751
859
 
752
- object = [databaseTransaction objectForKey:key inCollection:collection];
860
+ object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
753
861
  block(secondaryIndexConnection->blockDict, collection, key, object, metadata);
754
862
  }
755
863
 
@@ -775,7 +883,7 @@
775
883
  * YapDatabase extension hook.
776
884
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
777
885
  **/
778
- - (void)handleTouchObjectForKey:(NSString *)key inCollection:(NSString *)collection withRowid:(int64_t)rowid
886
+ - (void)handleTouchObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
779
887
  {
780
888
  // Nothing to do for this extension
781
889
  }
@@ -784,7 +892,7 @@
784
892
  * YapDatabase extension hook.
785
893
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
786
894
  **/
787
- - (void)handleTouchMetadataForKey:(NSString *)key inCollection:(NSString *)collection withRowid:(int64_t)rowid
895
+ - (void)handleTouchMetadataForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
788
896
  {
789
897
  // Nothing to do for this extension
790
898
  }
@@ -793,7 +901,7 @@
793
901
  * YapDatabase extension hook.
794
902
  * This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
795
903
  **/
796
- - (void)handleRemoveObjectForKey:(NSString *)key inCollection:(NSString *)collection withRowid:(int64_t)rowid
904
+ - (void)handleRemoveObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
797
905
  {
798
906
  YDBLogAutoTrace();
799
907
 
@@ -958,11 +1066,9 @@
958
1066
 
959
1067
  BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
960
1068
 
961
- NSString *key = nil;
962
- NSString *collection = nil;
963
- [databaseTransaction getKey:&key collection:&collection forRowid:rowid];
1069
+ YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
964
1070
 
965
- block(collection, key, stop);
1071
+ block(ck.collection, ck.key, stop);
966
1072
  }];
967
1073
 
968
1074
  return result;
@@ -977,12 +1083,11 @@
977
1083
 
978
1084
  BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
979
1085
 
980
- NSString *key = nil;
981
- NSString *collection = nil;
1086
+ YapCollectionKey *ck = nil;
982
1087
  id metadata = nil;
983
- [databaseTransaction getKey:&key collection:&collection metadata:&metadata forRowid:rowid];
1088
+ [databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
984
1089
 
985
- block(collection, key, metadata, stop);
1090
+ block(ck.collection, ck.key, metadata, stop);
986
1091
  }];
987
1092
 
988
1093
  return result;
@@ -997,12 +1102,11 @@
997
1102
 
998
1103
  BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
999
1104
 
1000
- NSString *key = nil;
1001
- NSString *collection = nil;
1105
+ YapCollectionKey *ck = nil;
1002
1106
  id object = nil;
1003
- [databaseTransaction getKey:&key collection:&collection object:&object forRowid:rowid];
1107
+ [databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
1004
1108
 
1005
- block(collection, key, object, stop);
1109
+ block(ck.collection, ck.key, object, stop);
1006
1110
  }];
1007
1111
 
1008
1112
  return result;
@@ -1017,13 +1121,12 @@
1017
1121
 
1018
1122
  BOOL result = [self _enumerateRowidsMatchingQuery:query usingBlock:^(int64_t rowid, BOOL *stop) {
1019
1123
 
1020
- NSString *key = nil;
1021
- NSString *collection = nil;
1124
+ YapCollectionKey *ck = nil;
1022
1125
  id object = nil;
1023
1126
  id metadata = nil;
1024
- [databaseTransaction getKey:&key collection:&collection object:&object metadata:&metadata forRowid:rowid];
1127
+ [databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
1025
1128
 
1026
- block(collection, key, object, metadata, stop);
1129
+ block(ck.collection, ck.key, object, metadata, stop);
1027
1130
  }];
1028
1131
 
1029
1132
  return result;