hyper-mesh 0.6.0 → 1.0.0.lap22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (722) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -4
  3. data/.travis.yml +25 -2
  4. data/DOCS.md +722 -0
  5. data/Gemfile +2 -8
  6. data/README.md +32 -264
  7. data/Rakefile +7 -5
  8. data/dciy.toml +3 -0
  9. data/hyper-mesh.gemspec +59 -81
  10. data/lib/active_record_base.rb +3 -3
  11. data/lib/hypermesh/version.rb +1 -1
  12. data/lib/opal/parse_patch.rb +1 -1
  13. data/lib/reactive_record/active_record/aggregations.rb +1 -1
  14. data/lib/reactive_record/active_record/associations.rb +1 -5
  15. data/lib/reactive_record/active_record/class_methods.rb +6 -23
  16. data/lib/reactive_record/active_record/instance_methods.rb +30 -10
  17. data/lib/reactive_record/active_record/public_columns_hash.rb +27 -8
  18. data/lib/reactive_record/active_record/reactive_record/collection.rb +1 -1
  19. data/lib/reactive_record/active_record/reactive_record/column_types.rb +7 -1
  20. data/lib/reactive_record/active_record/reactive_record/dummy_value.rb +28 -15
  21. data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +23 -12
  22. data/lib/reactive_record/active_record/reactive_record/while_loading.rb +84 -53
  23. data/lib/reactive_record/engine.rb +1 -1
  24. data/lib/reactive_record/server_data_cache.rb +99 -44
  25. metadata +101 -984
  26. data/docs/action_cable_quickstart.md +0 -134
  27. data/docs/activerecord_api.md +0 -275
  28. data/docs/authorization-policies.md +0 -502
  29. data/docs/client_side_scoping.md +0 -103
  30. data/docs/configuration_details.md +0 -33
  31. data/docs/pusher_faker_quickstart.md +0 -56
  32. data/docs/pusher_quickstart.md +0 -44
  33. data/docs/simple_poller_quickstart.md +0 -31
  34. data/docs/todo-example.md +0 -118
  35. data/docs/word_game.md +0 -28
  36. data/docs/words-example.md +0 -67
  37. data/examples/action-cable-production-mode/.gitignore +0 -21
  38. data/examples/action-cable-production-mode/Gemfile +0 -57
  39. data/examples/action-cable-production-mode/Gemfile.lock +0 -231
  40. data/examples/action-cable-production-mode/README.md +0 -24
  41. data/examples/action-cable-production-mode/Rakefile +0 -6
  42. data/examples/action-cable-production-mode/app/assets/config/manifest.js +0 -3
  43. data/examples/action-cable-production-mode/app/assets/images/.keep +0 -0
  44. data/examples/action-cable-production-mode/app/assets/javascripts/application.js +0 -20
  45. data/examples/action-cable-production-mode/app/assets/javascripts/cable.js +0 -13
  46. data/examples/action-cable-production-mode/app/assets/javascripts/channels/.keep +0 -0
  47. data/examples/action-cable-production-mode/app/assets/stylesheets/application.css +0 -15
  48. data/examples/action-cable-production-mode/app/channels/application_cable/channel.rb +0 -4
  49. data/examples/action-cable-production-mode/app/channels/application_cable/connection.rb +0 -4
  50. data/examples/action-cable-production-mode/app/controllers/application_controller.rb +0 -3
  51. data/examples/action-cable-production-mode/app/controllers/test_controller.rb +0 -5
  52. data/examples/action-cable-production-mode/app/models/models.rb +0 -2
  53. data/examples/action-cable-production-mode/app/models/public/application_record.rb +0 -3
  54. data/examples/action-cable-production-mode/app/models/public/word.rb +0 -2
  55. data/examples/action-cable-production-mode/app/policies/application_policy.rb +0 -14
  56. data/examples/action-cable-production-mode/app/views/components.rb +0 -16
  57. data/examples/action-cable-production-mode/app/views/components/app.rb +0 -18
  58. data/examples/action-cable-production-mode/app/views/layouts/application.html.erb +0 -14
  59. data/examples/action-cable-production-mode/bin/bundle +0 -3
  60. data/examples/action-cable-production-mode/bin/rails +0 -9
  61. data/examples/action-cable-production-mode/bin/rake +0 -9
  62. data/examples/action-cable-production-mode/bin/setup +0 -34
  63. data/examples/action-cable-production-mode/bin/spring +0 -16
  64. data/examples/action-cable-production-mode/bin/update +0 -29
  65. data/examples/action-cable-production-mode/config.ru +0 -5
  66. data/examples/action-cable-production-mode/config/application.rb +0 -18
  67. data/examples/action-cable-production-mode/config/boot.rb +0 -3
  68. data/examples/action-cable-production-mode/config/cable.yml +0 -9
  69. data/examples/action-cable-production-mode/config/database.yml +0 -25
  70. data/examples/action-cable-production-mode/config/environment.rb +0 -5
  71. data/examples/action-cable-production-mode/config/environments/development.rb +0 -56
  72. data/examples/action-cable-production-mode/config/environments/production.rb +0 -89
  73. data/examples/action-cable-production-mode/config/environments/test.rb +0 -42
  74. data/examples/action-cable-production-mode/config/initializers/application_controller_renderer.rb +0 -6
  75. data/examples/action-cable-production-mode/config/initializers/assets.rb +0 -11
  76. data/examples/action-cable-production-mode/config/initializers/backtrace_silencers.rb +0 -7
  77. data/examples/action-cable-production-mode/config/initializers/cookies_serializer.rb +0 -5
  78. data/examples/action-cable-production-mode/config/initializers/filter_parameter_logging.rb +0 -4
  79. data/examples/action-cable-production-mode/config/initializers/hyper_mesh.rb +0 -4
  80. data/examples/action-cable-production-mode/config/initializers/inflections.rb +0 -16
  81. data/examples/action-cable-production-mode/config/initializers/mime_types.rb +0 -4
  82. data/examples/action-cable-production-mode/config/initializers/new_framework_defaults.rb +0 -24
  83. data/examples/action-cable-production-mode/config/initializers/session_store.rb +0 -3
  84. data/examples/action-cable-production-mode/config/initializers/wrap_parameters.rb +0 -14
  85. data/examples/action-cable-production-mode/config/locales/en.yml +0 -23
  86. data/examples/action-cable-production-mode/config/puma.rb +0 -47
  87. data/examples/action-cable-production-mode/config/routes.rb +0 -5
  88. data/examples/action-cable-production-mode/config/secrets.yml +0 -22
  89. data/examples/action-cable-production-mode/config/spring.rb +0 -6
  90. data/examples/action-cable-production-mode/db/migrate/20161114213840_create_words.rb +0 -9
  91. data/examples/action-cable-production-mode/db/schema.rb +0 -34
  92. data/examples/action-cable-production-mode/db/seeds.rb +0 -7
  93. data/examples/action-cable-production-mode/lib/assets/.keep +0 -0
  94. data/examples/action-cable-production-mode/lib/tasks/.keep +0 -0
  95. data/examples/action-cable-production-mode/public/404.html +0 -67
  96. data/examples/action-cable-production-mode/public/422.html +0 -67
  97. data/examples/action-cable-production-mode/public/500.html +0 -66
  98. data/examples/action-cable-production-mode/public/apple-touch-icon-precomposed.png +0 -0
  99. data/examples/action-cable-production-mode/public/apple-touch-icon.png +0 -0
  100. data/examples/action-cable-production-mode/public/assets/.sprockets-manifest-3e9abd3ee8ba47c39a55b61ae37ed9e1.json +0 -1
  101. data/examples/action-cable-production-mode/public/favicon.ico +0 -0
  102. data/examples/action-cable-production-mode/public/robots.txt +0 -5
  103. data/examples/action-cable-production-mode/test/controllers/.keep +0 -0
  104. data/examples/action-cable-production-mode/test/fixtures/.keep +0 -0
  105. data/examples/action-cable-production-mode/test/fixtures/files/.keep +0 -0
  106. data/examples/action-cable-production-mode/test/fixtures/words.yml +0 -7
  107. data/examples/action-cable-production-mode/test/helpers/.keep +0 -0
  108. data/examples/action-cable-production-mode/test/integration/.keep +0 -0
  109. data/examples/action-cable-production-mode/test/mailers/.keep +0 -0
  110. data/examples/action-cable-production-mode/test/models/.keep +0 -0
  111. data/examples/action-cable-production-mode/test/models/word_test.rb +0 -7
  112. data/examples/action-cable-production-mode/test/test_helper.rb +0 -10
  113. data/examples/action-cable-production-mode/vendor/assets/javascripts/.keep +0 -0
  114. data/examples/action-cable-production-mode/vendor/assets/stylesheets/.keep +0 -0
  115. data/examples/action-cable/.gitignore +0 -21
  116. data/examples/action-cable/Gemfile +0 -58
  117. data/examples/action-cable/Gemfile.lock +0 -248
  118. data/examples/action-cable/README.md +0 -24
  119. data/examples/action-cable/Rakefile +0 -6
  120. data/examples/action-cable/app/assets/config/manifest.js +0 -3
  121. data/examples/action-cable/app/assets/images/.keep +0 -0
  122. data/examples/action-cable/app/assets/javascripts/application.js +0 -20
  123. data/examples/action-cable/app/assets/javascripts/cable.js +0 -13
  124. data/examples/action-cable/app/assets/javascripts/channels/.keep +0 -0
  125. data/examples/action-cable/app/assets/stylesheets/application.css +0 -15
  126. data/examples/action-cable/app/channels/application_cable/channel.rb +0 -4
  127. data/examples/action-cable/app/channels/application_cable/connection.rb +0 -4
  128. data/examples/action-cable/app/controllers/application_controller.rb +0 -3
  129. data/examples/action-cable/app/controllers/test_controller.rb +0 -5
  130. data/examples/action-cable/app/models/models.rb +0 -2
  131. data/examples/action-cable/app/models/public/.keep +0 -0
  132. data/examples/action-cable/app/models/public/application_record.rb +0 -3
  133. data/examples/action-cable/app/models/public/word.rb +0 -2
  134. data/examples/action-cable/app/policies/application_policy.rb +0 -14
  135. data/examples/action-cable/app/views/components.rb +0 -16
  136. data/examples/action-cable/app/views/components/app.rb +0 -18
  137. data/examples/action-cable/app/views/layouts/application.html.erb +0 -14
  138. data/examples/action-cable/bin/bundle +0 -3
  139. data/examples/action-cable/bin/rails +0 -9
  140. data/examples/action-cable/bin/rake +0 -9
  141. data/examples/action-cable/bin/setup +0 -34
  142. data/examples/action-cable/bin/spring +0 -16
  143. data/examples/action-cable/bin/update +0 -29
  144. data/examples/action-cable/config.ru +0 -5
  145. data/examples/action-cable/config/application.rb +0 -20
  146. data/examples/action-cable/config/boot.rb +0 -3
  147. data/examples/action-cable/config/cable.yml +0 -9
  148. data/examples/action-cable/config/database.yml +0 -25
  149. data/examples/action-cable/config/environment.rb +0 -5
  150. data/examples/action-cable/config/environments/development.rb +0 -56
  151. data/examples/action-cable/config/environments/production.rb +0 -86
  152. data/examples/action-cable/config/environments/test.rb +0 -42
  153. data/examples/action-cable/config/initializers/application_controller_renderer.rb +0 -6
  154. data/examples/action-cable/config/initializers/assets.rb +0 -11
  155. data/examples/action-cable/config/initializers/backtrace_silencers.rb +0 -7
  156. data/examples/action-cable/config/initializers/cookies_serializer.rb +0 -5
  157. data/examples/action-cable/config/initializers/filter_parameter_logging.rb +0 -4
  158. data/examples/action-cable/config/initializers/hyperloop.rb +0 -4
  159. data/examples/action-cable/config/initializers/inflections.rb +0 -16
  160. data/examples/action-cable/config/initializers/mime_types.rb +0 -4
  161. data/examples/action-cable/config/initializers/new_framework_defaults.rb +0 -24
  162. data/examples/action-cable/config/initializers/session_store.rb +0 -3
  163. data/examples/action-cable/config/initializers/wrap_parameters.rb +0 -14
  164. data/examples/action-cable/config/locales/en.yml +0 -23
  165. data/examples/action-cable/config/puma.rb +0 -47
  166. data/examples/action-cable/config/routes.rb +0 -5
  167. data/examples/action-cable/config/secrets.yml +0 -22
  168. data/examples/action-cable/config/spring.rb +0 -6
  169. data/examples/action-cable/db/migrate/20161114213840_create_words.rb +0 -9
  170. data/examples/action-cable/db/schema.rb +0 -34
  171. data/examples/action-cable/db/seeds.rb +0 -7
  172. data/examples/action-cable/lib/assets/.keep +0 -0
  173. data/examples/action-cable/lib/tasks/.keep +0 -0
  174. data/examples/action-cable/public/404.html +0 -67
  175. data/examples/action-cable/public/422.html +0 -67
  176. data/examples/action-cable/public/500.html +0 -66
  177. data/examples/action-cable/public/apple-touch-icon-precomposed.png +0 -0
  178. data/examples/action-cable/public/apple-touch-icon.png +0 -0
  179. data/examples/action-cable/public/favicon.ico +0 -0
  180. data/examples/action-cable/public/robots.txt +0 -5
  181. data/examples/action-cable/test/controllers/.keep +0 -0
  182. data/examples/action-cable/test/fixtures/.keep +0 -0
  183. data/examples/action-cable/test/fixtures/files/.keep +0 -0
  184. data/examples/action-cable/test/fixtures/words.yml +0 -7
  185. data/examples/action-cable/test/helpers/.keep +0 -0
  186. data/examples/action-cable/test/integration/.keep +0 -0
  187. data/examples/action-cable/test/mailers/.keep +0 -0
  188. data/examples/action-cable/test/models/.keep +0 -0
  189. data/examples/action-cable/test/models/word_test.rb +0 -7
  190. data/examples/action-cable/test/test_helper.rb +0 -10
  191. data/examples/action-cable/vendor/assets/javascripts/.keep +0 -0
  192. data/examples/action-cable/vendor/assets/stylesheets/.keep +0 -0
  193. data/examples/pusher-fake/.gitignore +0 -21
  194. data/examples/pusher-fake/Gemfile +0 -59
  195. data/examples/pusher-fake/Gemfile.lock +0 -262
  196. data/examples/pusher-fake/README.md +0 -24
  197. data/examples/pusher-fake/Rakefile +0 -6
  198. data/examples/pusher-fake/app/assets/config/manifest.js +0 -3
  199. data/examples/pusher-fake/app/assets/images/.keep +0 -0
  200. data/examples/pusher-fake/app/assets/javascripts/application.js +0 -21
  201. data/examples/pusher-fake/app/assets/stylesheets/application.css +0 -15
  202. data/examples/pusher-fake/app/controllers/application_controller.rb +0 -3
  203. data/examples/pusher-fake/app/controllers/test_controller.rb +0 -5
  204. data/examples/pusher-fake/app/models/models.rb +0 -2
  205. data/examples/pusher-fake/app/models/public/.keep +0 -0
  206. data/examples/pusher-fake/app/models/public/application_record.rb +0 -3
  207. data/examples/pusher-fake/app/models/public/word.rb +0 -2
  208. data/examples/pusher-fake/app/policies/application_policy.rb +0 -14
  209. data/examples/pusher-fake/app/views/components.rb +0 -16
  210. data/examples/pusher-fake/app/views/components/app.rb +0 -18
  211. data/examples/pusher-fake/app/views/layouts/application.html.erb +0 -14
  212. data/examples/pusher-fake/bin/bundle +0 -3
  213. data/examples/pusher-fake/bin/rails +0 -9
  214. data/examples/pusher-fake/bin/rake +0 -9
  215. data/examples/pusher-fake/bin/setup +0 -34
  216. data/examples/pusher-fake/bin/spring +0 -16
  217. data/examples/pusher-fake/bin/update +0 -29
  218. data/examples/pusher-fake/config.ru +0 -5
  219. data/examples/pusher-fake/config/application.rb +0 -20
  220. data/examples/pusher-fake/config/boot.rb +0 -3
  221. data/examples/pusher-fake/config/database.yml +0 -25
  222. data/examples/pusher-fake/config/environment.rb +0 -5
  223. data/examples/pusher-fake/config/environments/development.rb +0 -56
  224. data/examples/pusher-fake/config/environments/production.rb +0 -86
  225. data/examples/pusher-fake/config/environments/test.rb +0 -42
  226. data/examples/pusher-fake/config/initializers/application_controller_renderer.rb +0 -6
  227. data/examples/pusher-fake/config/initializers/assets.rb +0 -11
  228. data/examples/pusher-fake/config/initializers/backtrace_silencers.rb +0 -7
  229. data/examples/pusher-fake/config/initializers/cookies_serializer.rb +0 -5
  230. data/examples/pusher-fake/config/initializers/filter_parameter_logging.rb +0 -4
  231. data/examples/pusher-fake/config/initializers/hyper_mesh.rb +0 -21
  232. data/examples/pusher-fake/config/initializers/inflections.rb +0 -16
  233. data/examples/pusher-fake/config/initializers/mime_types.rb +0 -4
  234. data/examples/pusher-fake/config/initializers/new_framework_defaults.rb +0 -24
  235. data/examples/pusher-fake/config/initializers/session_store.rb +0 -3
  236. data/examples/pusher-fake/config/initializers/wrap_parameters.rb +0 -14
  237. data/examples/pusher-fake/config/locales/en.yml +0 -23
  238. data/examples/pusher-fake/config/puma.rb +0 -47
  239. data/examples/pusher-fake/config/routes.rb +0 -5
  240. data/examples/pusher-fake/config/secrets.yml +0 -22
  241. data/examples/pusher-fake/config/spring.rb +0 -6
  242. data/examples/pusher-fake/db/migrate/20161114213840_create_words.rb +0 -9
  243. data/examples/pusher-fake/db/schema.rb +0 -34
  244. data/examples/pusher-fake/db/seeds.rb +0 -7
  245. data/examples/pusher-fake/lib/assets/.keep +0 -0
  246. data/examples/pusher-fake/lib/tasks/.keep +0 -0
  247. data/examples/pusher-fake/public/404.html +0 -67
  248. data/examples/pusher-fake/public/422.html +0 -67
  249. data/examples/pusher-fake/public/500.html +0 -66
  250. data/examples/pusher-fake/public/apple-touch-icon-precomposed.png +0 -0
  251. data/examples/pusher-fake/public/apple-touch-icon.png +0 -0
  252. data/examples/pusher-fake/public/favicon.ico +0 -0
  253. data/examples/pusher-fake/public/robots.txt +0 -5
  254. data/examples/pusher-fake/test/controllers/.keep +0 -0
  255. data/examples/pusher-fake/test/fixtures/.keep +0 -0
  256. data/examples/pusher-fake/test/fixtures/files/.keep +0 -0
  257. data/examples/pusher-fake/test/fixtures/words.yml +0 -7
  258. data/examples/pusher-fake/test/helpers/.keep +0 -0
  259. data/examples/pusher-fake/test/integration/.keep +0 -0
  260. data/examples/pusher-fake/test/mailers/.keep +0 -0
  261. data/examples/pusher-fake/test/models/.keep +0 -0
  262. data/examples/pusher-fake/test/models/word_test.rb +0 -7
  263. data/examples/pusher-fake/test/test_helper.rb +0 -10
  264. data/examples/pusher-fake/vendor/assets/javascripts/.keep +0 -0
  265. data/examples/pusher-fake/vendor/assets/stylesheets/.keep +0 -0
  266. data/examples/pusher/.gitignore +0 -21
  267. data/examples/pusher/Gemfile +0 -58
  268. data/examples/pusher/Gemfile.lock +0 -236
  269. data/examples/pusher/README.md +0 -24
  270. data/examples/pusher/Rakefile +0 -6
  271. data/examples/pusher/app/assets/config/manifest.js +0 -3
  272. data/examples/pusher/app/assets/images/.keep +0 -0
  273. data/examples/pusher/app/assets/javascripts/application.js +0 -21
  274. data/examples/pusher/app/assets/stylesheets/application.css +0 -15
  275. data/examples/pusher/app/controllers/application_controller.rb +0 -3
  276. data/examples/pusher/app/controllers/test_controller.rb +0 -5
  277. data/examples/pusher/app/models/models.rb +0 -2
  278. data/examples/pusher/app/models/public/.keep +0 -0
  279. data/examples/pusher/app/models/public/application_record.rb +0 -3
  280. data/examples/pusher/app/models/public/word.rb +0 -2
  281. data/examples/pusher/app/policies/application_policy.rb +0 -14
  282. data/examples/pusher/app/views/components.rb +0 -16
  283. data/examples/pusher/app/views/components/app.rb +0 -18
  284. data/examples/pusher/app/views/layouts/application.html.erb +0 -14
  285. data/examples/pusher/bin/bundle +0 -3
  286. data/examples/pusher/bin/rails +0 -9
  287. data/examples/pusher/bin/rake +0 -9
  288. data/examples/pusher/bin/setup +0 -34
  289. data/examples/pusher/bin/spring +0 -16
  290. data/examples/pusher/bin/update +0 -29
  291. data/examples/pusher/config.ru +0 -5
  292. data/examples/pusher/config/application.rb +0 -20
  293. data/examples/pusher/config/boot.rb +0 -3
  294. data/examples/pusher/config/database.yml +0 -25
  295. data/examples/pusher/config/environment.rb +0 -5
  296. data/examples/pusher/config/environments/development.rb +0 -56
  297. data/examples/pusher/config/environments/production.rb +0 -86
  298. data/examples/pusher/config/environments/test.rb +0 -42
  299. data/examples/pusher/config/initializers/application_controller_renderer.rb +0 -6
  300. data/examples/pusher/config/initializers/assets.rb +0 -11
  301. data/examples/pusher/config/initializers/backtrace_silencers.rb +0 -7
  302. data/examples/pusher/config/initializers/cookies_serializer.rb +0 -5
  303. data/examples/pusher/config/initializers/filter_parameter_logging.rb +0 -4
  304. data/examples/pusher/config/initializers/hyper_mesh.rb +0 -10
  305. data/examples/pusher/config/initializers/inflections.rb +0 -16
  306. data/examples/pusher/config/initializers/mime_types.rb +0 -4
  307. data/examples/pusher/config/initializers/new_framework_defaults.rb +0 -24
  308. data/examples/pusher/config/initializers/session_store.rb +0 -3
  309. data/examples/pusher/config/initializers/wrap_parameters.rb +0 -14
  310. data/examples/pusher/config/locales/en.yml +0 -23
  311. data/examples/pusher/config/puma.rb +0 -47
  312. data/examples/pusher/config/routes.rb +0 -5
  313. data/examples/pusher/config/secrets.yml +0 -22
  314. data/examples/pusher/config/spring.rb +0 -6
  315. data/examples/pusher/db/migrate/20161114213840_create_words.rb +0 -9
  316. data/examples/pusher/db/schema.rb +0 -34
  317. data/examples/pusher/db/seeds.rb +0 -7
  318. data/examples/pusher/lib/assets/.keep +0 -0
  319. data/examples/pusher/lib/tasks/.keep +0 -0
  320. data/examples/pusher/public/404.html +0 -67
  321. data/examples/pusher/public/422.html +0 -67
  322. data/examples/pusher/public/500.html +0 -66
  323. data/examples/pusher/public/apple-touch-icon-precomposed.png +0 -0
  324. data/examples/pusher/public/apple-touch-icon.png +0 -0
  325. data/examples/pusher/public/favicon.ico +0 -0
  326. data/examples/pusher/public/robots.txt +0 -5
  327. data/examples/pusher/test/controllers/.keep +0 -0
  328. data/examples/pusher/test/fixtures/.keep +0 -0
  329. data/examples/pusher/test/fixtures/files/.keep +0 -0
  330. data/examples/pusher/test/fixtures/words.yml +0 -7
  331. data/examples/pusher/test/helpers/.keep +0 -0
  332. data/examples/pusher/test/integration/.keep +0 -0
  333. data/examples/pusher/test/mailers/.keep +0 -0
  334. data/examples/pusher/test/models/.keep +0 -0
  335. data/examples/pusher/test/models/word_test.rb +0 -7
  336. data/examples/pusher/test/test_helper.rb +0 -10
  337. data/examples/pusher/vendor/assets/javascripts/.keep +0 -0
  338. data/examples/pusher/vendor/assets/stylesheets/.keep +0 -0
  339. data/examples/simple-poller/.gitignore +0 -21
  340. data/examples/simple-poller/Gemfile +0 -57
  341. data/examples/simple-poller/Gemfile.lock +0 -229
  342. data/examples/simple-poller/README.md +0 -24
  343. data/examples/simple-poller/Rakefile +0 -6
  344. data/examples/simple-poller/app/assets/config/manifest.js +0 -3
  345. data/examples/simple-poller/app/assets/images/.keep +0 -0
  346. data/examples/simple-poller/app/assets/javascripts/application.js +0 -21
  347. data/examples/simple-poller/app/assets/stylesheets/application.css +0 -15
  348. data/examples/simple-poller/app/controllers/application_controller.rb +0 -3
  349. data/examples/simple-poller/app/controllers/test_controller.rb +0 -5
  350. data/examples/simple-poller/app/models/models.rb +0 -2
  351. data/examples/simple-poller/app/models/public/.keep +0 -0
  352. data/examples/simple-poller/app/models/public/application_record.rb +0 -3
  353. data/examples/simple-poller/app/models/public/word.rb +0 -2
  354. data/examples/simple-poller/app/policies/application_policy.rb +0 -14
  355. data/examples/simple-poller/app/views/components.rb +0 -16
  356. data/examples/simple-poller/app/views/components/app.rb +0 -18
  357. data/examples/simple-poller/app/views/layouts/application.html.erb +0 -14
  358. data/examples/simple-poller/bin/bundle +0 -3
  359. data/examples/simple-poller/bin/rails +0 -9
  360. data/examples/simple-poller/bin/rake +0 -9
  361. data/examples/simple-poller/bin/setup +0 -34
  362. data/examples/simple-poller/bin/spring +0 -16
  363. data/examples/simple-poller/bin/update +0 -29
  364. data/examples/simple-poller/config.ru +0 -5
  365. data/examples/simple-poller/config/application.rb +0 -20
  366. data/examples/simple-poller/config/boot.rb +0 -3
  367. data/examples/simple-poller/config/database.yml +0 -25
  368. data/examples/simple-poller/config/environment.rb +0 -5
  369. data/examples/simple-poller/config/environments/development.rb +0 -56
  370. data/examples/simple-poller/config/environments/production.rb +0 -86
  371. data/examples/simple-poller/config/environments/test.rb +0 -42
  372. data/examples/simple-poller/config/initializers/application_controller_renderer.rb +0 -6
  373. data/examples/simple-poller/config/initializers/assets.rb +0 -11
  374. data/examples/simple-poller/config/initializers/backtrace_silencers.rb +0 -7
  375. data/examples/simple-poller/config/initializers/cookies_serializer.rb +0 -5
  376. data/examples/simple-poller/config/initializers/filter_parameter_logging.rb +0 -4
  377. data/examples/simple-poller/config/initializers/hyper_mesh.rb +0 -9
  378. data/examples/simple-poller/config/initializers/inflections.rb +0 -16
  379. data/examples/simple-poller/config/initializers/mime_types.rb +0 -4
  380. data/examples/simple-poller/config/initializers/new_framework_defaults.rb +0 -24
  381. data/examples/simple-poller/config/initializers/session_store.rb +0 -3
  382. data/examples/simple-poller/config/initializers/wrap_parameters.rb +0 -14
  383. data/examples/simple-poller/config/locales/en.yml +0 -23
  384. data/examples/simple-poller/config/puma.rb +0 -47
  385. data/examples/simple-poller/config/routes.rb +0 -5
  386. data/examples/simple-poller/config/secrets.yml +0 -22
  387. data/examples/simple-poller/config/spring.rb +0 -6
  388. data/examples/simple-poller/db/migrate/20161114213840_create_words.rb +0 -9
  389. data/examples/simple-poller/db/schema.rb +0 -34
  390. data/examples/simple-poller/db/seeds.rb +0 -7
  391. data/examples/simple-poller/lib/assets/.keep +0 -0
  392. data/examples/simple-poller/lib/tasks/.keep +0 -0
  393. data/examples/simple-poller/public/404.html +0 -67
  394. data/examples/simple-poller/public/422.html +0 -67
  395. data/examples/simple-poller/public/500.html +0 -66
  396. data/examples/simple-poller/public/apple-touch-icon-precomposed.png +0 -0
  397. data/examples/simple-poller/public/apple-touch-icon.png +0 -0
  398. data/examples/simple-poller/public/favicon.ico +0 -0
  399. data/examples/simple-poller/public/robots.txt +0 -5
  400. data/examples/simple-poller/test/controllers/.keep +0 -0
  401. data/examples/simple-poller/test/fixtures/.keep +0 -0
  402. data/examples/simple-poller/test/fixtures/files/.keep +0 -0
  403. data/examples/simple-poller/test/fixtures/words.yml +0 -7
  404. data/examples/simple-poller/test/helpers/.keep +0 -0
  405. data/examples/simple-poller/test/integration/.keep +0 -0
  406. data/examples/simple-poller/test/mailers/.keep +0 -0
  407. data/examples/simple-poller/test/models/.keep +0 -0
  408. data/examples/simple-poller/test/models/word_test.rb +0 -7
  409. data/examples/simple-poller/test/test_helper.rb +0 -10
  410. data/examples/simple-poller/vendor/assets/javascripts/.keep +0 -0
  411. data/examples/simple-poller/vendor/assets/stylesheets/.keep +0 -0
  412. data/examples/word-game/.gitignore +0 -21
  413. data/examples/word-game/Gemfile +0 -57
  414. data/examples/word-game/Gemfile.lock +0 -241
  415. data/examples/word-game/README.md +0 -24
  416. data/examples/word-game/Rakefile +0 -6
  417. data/examples/word-game/app/assets/config/manifest.js +0 -3
  418. data/examples/word-game/app/assets/images/.keep +0 -0
  419. data/examples/word-game/app/assets/javascripts/application.js +0 -20
  420. data/examples/word-game/app/assets/javascripts/cable.js +0 -13
  421. data/examples/word-game/app/assets/javascripts/channels/.keep +0 -0
  422. data/examples/word-game/app/assets/stylesheets/application.css +0 -15
  423. data/examples/word-game/app/channels/application_cable/channel.rb +0 -4
  424. data/examples/word-game/app/channels/application_cable/connection.rb +0 -4
  425. data/examples/word-game/app/controllers/application_controller.rb +0 -3
  426. data/examples/word-game/app/controllers/concerns/.keep +0 -0
  427. data/examples/word-game/app/helpers/application_helper.rb +0 -2
  428. data/examples/word-game/app/jobs/application_job.rb +0 -2
  429. data/examples/word-game/app/mailers/application_mailer.rb +0 -4
  430. data/examples/word-game/app/models/application_record.rb +0 -3
  431. data/examples/word-game/app/models/concerns/.keep +0 -0
  432. data/examples/word-game/app/models/models.rb +0 -2
  433. data/examples/word-game/app/models/public/.keep +0 -0
  434. data/examples/word-game/app/policies/application_policy.rb +0 -14
  435. data/examples/word-game/app/views/components.rb +0 -16
  436. data/examples/word-game/app/views/components/.keep +0 -0
  437. data/examples/word-game/app/views/layouts/application.html.erb +0 -14
  438. data/examples/word-game/app/views/layouts/mailer.html.erb +0 -13
  439. data/examples/word-game/app/views/layouts/mailer.text.erb +0 -1
  440. data/examples/word-game/bin/bundle +0 -3
  441. data/examples/word-game/bin/rails +0 -9
  442. data/examples/word-game/bin/rake +0 -9
  443. data/examples/word-game/bin/setup +0 -34
  444. data/examples/word-game/bin/spring +0 -16
  445. data/examples/word-game/bin/update +0 -29
  446. data/examples/word-game/config.ru +0 -5
  447. data/examples/word-game/config/application.rb +0 -20
  448. data/examples/word-game/config/boot.rb +0 -3
  449. data/examples/word-game/config/cable.yml +0 -9
  450. data/examples/word-game/config/database.yml +0 -25
  451. data/examples/word-game/config/environment.rb +0 -5
  452. data/examples/word-game/config/environments/development.rb +0 -56
  453. data/examples/word-game/config/environments/production.rb +0 -86
  454. data/examples/word-game/config/environments/test.rb +0 -42
  455. data/examples/word-game/config/initializers/application_controller_renderer.rb +0 -6
  456. data/examples/word-game/config/initializers/assets.rb +0 -11
  457. data/examples/word-game/config/initializers/backtrace_silencers.rb +0 -7
  458. data/examples/word-game/config/initializers/cookies_serializer.rb +0 -5
  459. data/examples/word-game/config/initializers/filter_parameter_logging.rb +0 -4
  460. data/examples/word-game/config/initializers/hyper_mesh.rb +0 -4
  461. data/examples/word-game/config/initializers/inflections.rb +0 -16
  462. data/examples/word-game/config/initializers/mime_types.rb +0 -4
  463. data/examples/word-game/config/initializers/new_framework_defaults.rb +0 -24
  464. data/examples/word-game/config/initializers/session_store.rb +0 -3
  465. data/examples/word-game/config/initializers/wrap_parameters.rb +0 -14
  466. data/examples/word-game/config/locales/en.yml +0 -23
  467. data/examples/word-game/config/puma.rb +0 -47
  468. data/examples/word-game/config/routes.rb +0 -4
  469. data/examples/word-game/config/secrets.yml +0 -22
  470. data/examples/word-game/config/spring.rb +0 -6
  471. data/examples/word-game/db/seeds.rb +0 -7
  472. data/examples/word-game/lib/assets/.keep +0 -0
  473. data/examples/word-game/lib/tasks/.keep +0 -0
  474. data/examples/word-game/public/404.html +0 -67
  475. data/examples/word-game/public/422.html +0 -67
  476. data/examples/word-game/public/500.html +0 -66
  477. data/examples/word-game/public/apple-touch-icon-precomposed.png +0 -0
  478. data/examples/word-game/public/apple-touch-icon.png +0 -0
  479. data/examples/word-game/public/favicon.ico +0 -0
  480. data/examples/word-game/public/robots.txt +0 -5
  481. data/examples/word-game/test/controllers/.keep +0 -0
  482. data/examples/word-game/test/fixtures/.keep +0 -0
  483. data/examples/word-game/test/fixtures/files/.keep +0 -0
  484. data/examples/word-game/test/helpers/.keep +0 -0
  485. data/examples/word-game/test/integration/.keep +0 -0
  486. data/examples/word-game/test/mailers/.keep +0 -0
  487. data/examples/word-game/test/models/.keep +0 -0
  488. data/examples/word-game/test/test_helper.rb +0 -10
  489. data/examples/word-game/vendor/assets/javascripts/.keep +0 -0
  490. data/examples/word-game/vendor/assets/stylesheets/.keep +0 -0
  491. data/examples/words/.gitignore +0 -21
  492. data/examples/words/Gemfile +0 -59
  493. data/examples/words/Gemfile.lock +0 -248
  494. data/examples/words/README.md +0 -24
  495. data/examples/words/Rakefile +0 -6
  496. data/examples/words/app/assets/config/manifest.js +0 -3
  497. data/examples/words/app/assets/javascripts/application.js +0 -18
  498. data/examples/words/app/assets/stylesheets/application.css +0 -15
  499. data/examples/words/app/controllers/application_controller.rb +0 -3
  500. data/examples/words/app/controllers/test_controller.rb +0 -6
  501. data/examples/words/app/models/models.rb +0 -2
  502. data/examples/words/app/models/public/application_record.rb +0 -3
  503. data/examples/words/app/models/public/word.rb +0 -10
  504. data/examples/words/app/policies/application_policy.rb +0 -6
  505. data/examples/words/app/views/components.rb +0 -18
  506. data/examples/words/app/views/components/app.rb +0 -31
  507. data/examples/words/app/views/layouts/application.html.erb +0 -14
  508. data/examples/words/app/views/layouts/mailer.html.erb +0 -13
  509. data/examples/words/app/views/layouts/mailer.text.erb +0 -1
  510. data/examples/words/bin/bundle +0 -3
  511. data/examples/words/bin/rails +0 -9
  512. data/examples/words/bin/rake +0 -9
  513. data/examples/words/bin/setup +0 -34
  514. data/examples/words/bin/spring +0 -15
  515. data/examples/words/bin/update +0 -29
  516. data/examples/words/config.ru +0 -5
  517. data/examples/words/config/application.rb +0 -30
  518. data/examples/words/config/boot.rb +0 -3
  519. data/examples/words/config/cable.yml +0 -9
  520. data/examples/words/config/database.yml +0 -25
  521. data/examples/words/config/environment.rb +0 -5
  522. data/examples/words/config/environments/development.rb +0 -45
  523. data/examples/words/config/environments/production.rb +0 -86
  524. data/examples/words/config/environments/test.rb +0 -42
  525. data/examples/words/config/initializers/application_controller_renderer.rb +0 -6
  526. data/examples/words/config/initializers/assets.rb +0 -11
  527. data/examples/words/config/initializers/backtrace_silencers.rb +0 -7
  528. data/examples/words/config/initializers/cookies_serializer.rb +0 -5
  529. data/examples/words/config/initializers/filter_parameter_logging.rb +0 -4
  530. data/examples/words/config/initializers/hyper_mesh.rb +0 -14
  531. data/examples/words/config/initializers/inflections.rb +0 -16
  532. data/examples/words/config/initializers/mime_types.rb +0 -4
  533. data/examples/words/config/initializers/new_framework_defaults.rb +0 -24
  534. data/examples/words/config/initializers/session_store.rb +0 -3
  535. data/examples/words/config/initializers/wrap_parameters.rb +0 -14
  536. data/examples/words/config/locales/en.yml +0 -23
  537. data/examples/words/config/puma.rb +0 -47
  538. data/examples/words/config/routes.rb +0 -5
  539. data/examples/words/config/secrets.yml +0 -22
  540. data/examples/words/config/spring.rb +0 -6
  541. data/examples/words/db/migrate/20160921223808_create_words.rb +0 -9
  542. data/examples/words/db/schema.rb +0 -28
  543. data/examples/words/public/404.html +0 -67
  544. data/examples/words/public/422.html +0 -67
  545. data/examples/words/public/500.html +0 -66
  546. data/examples/words/public/apple-touch-icon-precomposed.png +0 -0
  547. data/examples/words/public/apple-touch-icon.png +0 -0
  548. data/examples/words/public/favicon.ico +0 -0
  549. data/examples/words/public/robots.txt +0 -5
  550. data/examples/words/vendor/assets/javascripts/.keep +0 -0
  551. data/examples/words/vendor/assets/stylesheets/.keep +0 -0
  552. data/reactive_record_test_app/Gemfile +0 -20
  553. data/reactive_record_test_app/Gemfile.lock +0 -269
  554. data/reactive_record_test_app/Rakefile +0 -7
  555. data/reactive_record_test_app/app/assets/javascripts/application.rb +0 -3
  556. data/reactive_record_test_app/app/assets/javascripts/bigdecimal.rb +0 -1
  557. data/reactive_record_test_app/app/assets/javascripts/reactive_record_config.js +0 -2
  558. data/reactive_record_test_app/app/assets/stylesheets/application.css +0 -13
  559. data/reactive_record_test_app/app/controllers/application_controller.rb +0 -8
  560. data/reactive_record_test_app/app/controllers/home_controller.rb +0 -7
  561. data/reactive_record_test_app/app/helpers/application_helper.rb +0 -2
  562. data/reactive_record_test_app/app/models/models.rb.erb +0 -6
  563. data/reactive_record_test_app/app/models/public/address.rb +0 -13
  564. data/reactive_record_test_app/app/models/public/comment.rb +0 -19
  565. data/reactive_record_test_app/app/models/public/todo_item.rb +0 -36
  566. data/reactive_record_test_app/app/models/public/user.rb +0 -78
  567. data/reactive_record_test_app/config.ru +0 -33
  568. data/reactive_record_test_app/config/application.rb +0 -75
  569. data/reactive_record_test_app/config/boot.rb +0 -10
  570. data/reactive_record_test_app/config/database.yml +0 -25
  571. data/reactive_record_test_app/config/environment.rb +0 -5
  572. data/reactive_record_test_app/config/environments/development.rb +0 -43
  573. data/reactive_record_test_app/config/initializers/backtrace_silencers.rb +0 -7
  574. data/reactive_record_test_app/config/initializers/hyper_mesh_legacy_behavior.rb +0 -5
  575. data/reactive_record_test_app/config/initializers/inflections.rb +0 -15
  576. data/reactive_record_test_app/config/initializers/mime_types.rb +0 -5
  577. data/reactive_record_test_app/config/initializers/secret_token.rb +0 -7
  578. data/reactive_record_test_app/config/initializers/session_store.rb +0 -8
  579. data/reactive_record_test_app/config/initializers/wrap_parameters.rb +0 -14
  580. data/reactive_record_test_app/config/locales/en.yml +0 -5
  581. data/reactive_record_test_app/config/routes.rb +0 -6
  582. data/reactive_record_test_app/db/migrate/20150617002932_create_todo_items.rb +0 -11
  583. data/reactive_record_test_app/db/migrate/20150617134028_create_users.rb +0 -14
  584. data/reactive_record_test_app/db/migrate/20150729195556_add_address_to_user.rb +0 -20
  585. data/reactive_record_test_app/db/migrate/20150826142045_create_comments.rb +0 -10
  586. data/reactive_record_test_app/db/migrate/20150828172008_add_single_comment_to_todo_item.rb +0 -5
  587. data/reactive_record_test_app/db/migrate/20150908184118_add_address_id_to_user.rb +0 -5
  588. data/reactive_record_test_app/db/migrate/20150917220236_add_second_address_to_user.rb +0 -10
  589. data/reactive_record_test_app/db/migrate/20151009000111_add_test_data_attributes_to_user.rb +0 -6
  590. data/reactive_record_test_app/db/migrate/20160129182544_add_test_enum_to_user.rb +0 -5
  591. data/reactive_record_test_app/db/schema.rb +0 -63
  592. data/reactive_record_test_app/db/seeds.rb +0 -66
  593. data/reactive_record_test_app/public/404.html +0 -26
  594. data/reactive_record_test_app/public/422.html +0 -26
  595. data/reactive_record_test_app/public/500.html +0 -25
  596. data/reactive_record_test_app/public/favicon.ico +0 -0
  597. data/reactive_record_test_app/script/rails +0 -6
  598. data/reactive_record_test_app/spec-opal/active-record/aggregations_spec.rb +0 -41
  599. data/reactive_record_test_app/spec-opal/active-record/associations_spec.rb +0 -75
  600. data/reactive_record_test_app/spec-opal/active-record/base_spec.rb +0 -126
  601. data/reactive_record_test_app/spec-opal/active-record/dummy_value_spec.rb +0 -27
  602. data/reactive_record_test_app/spec-opal/active-record/edge_cases_spec.rb +0 -116
  603. data/reactive_record_test_app/spec-opal/active-record/enum_spec.rb +0 -43
  604. data/reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb +0 -53
  605. data/reactive_record_test_app/spec-opal/active-record/non_ar_aggregations_spec.rb +0 -74
  606. data/reactive_record_test_app/spec-opal/active-record/reactive_record_load_spec.rb +0 -23
  607. data/reactive_record_test_app/spec-opal/active-record/rendering_spec.rb +0 -230
  608. data/reactive_record_test_app/spec-opal/active-record/save_spec.rb +0 -124
  609. data/reactive_record_test_app/spec-opal/active-record/scope_spec.rb +0 -85
  610. data/reactive_record_test_app/spec-opal/active-record/update_aggregations_spec.rb +0 -76
  611. data/reactive_record_test_app/spec-opal/active-record/update_attributes_spec.rb +0 -186
  612. data/reactive_record_test_app/spec-opal/active-record/virtual_methods_spec.rb +0 -71
  613. data/reactive_record_test_app/spec-opal/index.html.erb +0 -11
  614. data/reactive_record_test_app/spec-opal/spec_helper.js.rb +0 -268
  615. data/reactive_record_test_app/spec-opal/test_spec.rb +0 -7
  616. data/reactive_record_test_app/spec-opal/vendor/es5-shim.min.js +0 -6
  617. data/reactive_record_test_app/spec_dont_run/README.md +0 -33
  618. data/reactive_record_test_app/spec_dont_run/active_record_broken/permissions_spec.rb +0 -170
  619. data/reactive_record_test_app/spec_dont_run/active_record_broken/prerendering_spec.rb +0 -50
  620. data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzmany_to_many_spec_moved_to_main_suite.rb +0 -30
  621. data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzrevert_record_spec_moved.rb +0 -78
  622. data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzupdate_associations_spec_moved.rb +0 -142
  623. data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzupdate_scopes_movedspec.rb +0 -48
  624. data/spec/batch1/aaa-unit_tests/connection_movedspec.rb +0 -144
  625. data/spec/batch1/aaa-unit_tests/dummy_value_spec.rb +0 -26
  626. data/spec/batch1/column_types/column_type_spec.rb +0 -318
  627. data/spec/batch1/crud_access_regulation/broadcast_controls_access_spec.rb +0 -99
  628. data/spec/batch1/crud_access_regulation/model_policies_spec.rb +0 -133
  629. data/spec/batch1/misc/access_like_hash_spec.rb +0 -43
  630. data/spec/batch1/misc/while_loading_spec.rb +0 -196
  631. data/spec/batch1/policies/regulate_all_broadcasts_spec.rb +0 -315
  632. data/spec/batch1/policies/regulate_broadcast_spec.rb +0 -370
  633. data/spec/batch2/authorization_spec.rb +0 -112
  634. data/spec/batch2/default_scope_spec.rb +0 -121
  635. data/spec/batch2/has_many_through_spec.rb +0 -169
  636. data/spec/batch2/relationships_spec.rb +0 -263
  637. data/spec/batch3/auto_load_itself_spec.rb +0 -24
  638. data/spec/batch3/edge_cases_spec.rb +0 -31
  639. data/spec/batch3/finder_method_spec.rb +0 -67
  640. data/spec/batch3/many_to_many_spec.rb +0 -50
  641. data/spec/batch3/pry_rescue_xspec.rb +0 -48
  642. data/spec/batch3/readme.txt +0 -0
  643. data/spec/batch3/revert_spec.rb +0 -113
  644. data/spec/batch3/save_while_loading_spec.rb +0 -44
  645. data/spec/batch3/update_associations_spec.rb +0 -189
  646. data/spec/batch3/update_scopes_spec.rb +0 -54
  647. data/spec/batch4/saving_during_commit_spec.rb +0 -64
  648. data/spec/batch4/scope_spec.rb +0 -581
  649. data/spec/batch4/scoped_todos_spec.rb +0 -167
  650. data/spec/batch4/synchromesh_spec.rb +0 -80
  651. data/spec/bin/firebug-2.0.13-fx.xpi +0 -0
  652. data/spec/component_helpers_xspec.rb +0 -49
  653. data/spec/examples/dictionary.rb +0 -239
  654. data/spec/examples/dictionary_with_client_scopes.rb +0 -196
  655. data/spec/examples/random_examples.rb +0 -133
  656. data/spec/factories/child_model.rb +0 -5
  657. data/spec/factories/comment.rb +0 -5
  658. data/spec/factories/test_models.rb +0 -5
  659. data/spec/factories/todo.rb +0 -5
  660. data/spec/factories/user.rb +0 -5
  661. data/spec/play_ground.rb +0 -64
  662. data/spec/reactive_record_factory.rb +0 -62
  663. data/spec/spec_helper.rb +0 -372
  664. data/spec/support/component_helpers.rb +0 -351
  665. data/spec/test_app/Gemfile +0 -66
  666. data/spec/test_app/Gemfile.lock +0 -303
  667. data/spec/test_app/Rakefile +0 -6
  668. data/spec/test_app/app/assets/javascripts/application.js +0 -6
  669. data/spec/test_app/app/assets/stylesheets/application.css +0 -15
  670. data/spec/test_app/app/controllers/application_controller.rb +0 -13
  671. data/spec/test_app/app/controllers/test_controller.rb +0 -5
  672. data/spec/test_app/app/models/_react_public_models.rb +0 -2
  673. data/spec/test_app/app/models/public/address.rb +0 -13
  674. data/spec/test_app/app/models/public/child_model.rb +0 -3
  675. data/spec/test_app/app/models/public/comment.rb +0 -25
  676. data/spec/test_app/app/models/public/test_model.rb +0 -5
  677. data/spec/test_app/app/models/public/todo.rb +0 -6
  678. data/spec/test_app/app/models/public/todo_item.rb +0 -36
  679. data/spec/test_app/app/models/public/user.rb +0 -88
  680. data/spec/test_app/app/policies/auto_loader_test_classa_policy.rb +0 -3
  681. data/spec/test_app/app/policies/auto_loader_test_classb_policy.rb +0 -3
  682. data/spec/test_app/app/policies/auto_loader_test_classc_policy.rb +0 -3
  683. data/spec/test_app/app/policies/auto_loader_test_classd_policy.rb +0 -3
  684. data/spec/test_app/app/views/components.rb +0 -13
  685. data/spec/test_app/app/views/components/show.rb +0 -5
  686. data/spec/test_app/app/views/layouts/application.html.erb +0 -14
  687. data/spec/test_app/bin/bundle +0 -3
  688. data/spec/test_app/bin/rails +0 -4
  689. data/spec/test_app/bin/rake +0 -4
  690. data/spec/test_app/bin/setup +0 -29
  691. data/spec/test_app/config.ru +0 -4
  692. data/spec/test_app/config/application.rb +0 -44
  693. data/spec/test_app/config/boot.rb +0 -6
  694. data/spec/test_app/config/cable.yml +0 -10
  695. data/spec/test_app/config/database.yml +0 -47
  696. data/spec/test_app/config/environment.rb +0 -5
  697. data/spec/test_app/config/environments/development.rb +0 -41
  698. data/spec/test_app/config/environments/production.rb +0 -79
  699. data/spec/test_app/config/environments/test.rb +0 -42
  700. data/spec/test_app/config/initializers/assets.rb +0 -11
  701. data/spec/test_app/config/initializers/backtrace_silencers.rb +0 -7
  702. data/spec/test_app/config/initializers/cookies_serializer.rb +0 -3
  703. data/spec/test_app/config/initializers/filter_parameter_logging.rb +0 -4
  704. data/spec/test_app/config/initializers/inflections.rb +0 -16
  705. data/spec/test_app/config/initializers/mime_types.rb +0 -4
  706. data/spec/test_app/config/initializers/session_store.rb +0 -3
  707. data/spec/test_app/config/initializers/synchromesh.rb +0 -11
  708. data/spec/test_app/config/initializers/wrap_parameters.rb +0 -14
  709. data/spec/test_app/config/locales/en.yml +0 -23
  710. data/spec/test_app/config/routes.rb +0 -61
  711. data/spec/test_app/config/secrets.yml +0 -22
  712. data/spec/test_app/db/development.sqlite3 +0 -0
  713. data/spec/test_app/db/migrate/20160731182106_create_test_models.rb +0 -75
  714. data/spec/test_app/db/schema.rb +0 -88
  715. data/spec/test_app/db/seeds.rb +0 -7
  716. data/spec/test_app/lib/assets/.keep +0 -0
  717. data/spec/test_app/public/404.html +0 -67
  718. data/spec/test_app/public/422.html +0 -67
  719. data/spec/test_app/public/500.html +0 -66
  720. data/spec/test_app/public/favicon.ico +0 -0
  721. data/spec/test_components.rb +0 -18
  722. data/spec/vendor/es5-shim.min.js +0 -6
@@ -1,134 +0,0 @@
1
- ### Action Cable Quickstart
2
-
3
- Action Cable is a production ready transport built into Rails 5.
4
-
5
- #### 1 Get Rails 5
6
-
7
- You need to be on rails 5 to use ActionCable. Make sure you upgrade to rails 5 first.
8
-
9
- #### 2 Add Hyperloop gems
10
-
11
- If you have not already installed the `hyper-component` and `hyper-model` gems, then do so now using the [hyper-rails](https://github.com/ruby-hyperloop/hyper-rails) gem.
12
-
13
- - add `gem 'hyper-rails'` to your gem file (in the development section)
14
- - run `bundle install`
15
- - run `rails g hyperloop:install --all` (make sure to use the --all option)
16
- - run `bundle update`
17
-
18
- #### 3 Set the transport
19
-
20
- TODO check below
21
-
22
- Once you have Hyperloop installed then add this initializer:
23
- ```ruby
24
- #config/initializers/hyperloop.rb
25
- Hyperloop.configuration do |config|
26
- config.transport = :action_cable
27
- end
28
- ```
29
-
30
- #### 4 Setup ActionCable
31
-
32
- If you are already using ActionCable in your app that is fine, as Hyperloop will not interfere with your existing connections.
33
-
34
- Otherwise go through the following steps to setup ActionCable.
35
-
36
- ##### Make sure the `action_cable` js file is required in your assets
37
-
38
- Typically `app/assets/javascripts/application.js` will finish with a `require_tree .` and this will pull in the `cable.js` file which will pull in `action_cable.js`
39
-
40
- However at a minimum if `application.js` simply does a `require action_cable` that will be sufficient for Hyperloop.
41
-
42
- ##### Make sure you have a cable.yml file
43
-
44
- ```yml
45
- # config/cable.yml
46
- development:
47
- adapter: async
48
-
49
- test:
50
- adapter: async
51
-
52
- production:
53
- adapter: redis
54
- url: redis://localhost:6379/1
55
- ```
56
-
57
- #### Set allowed request origins (optional)
58
-
59
- **By default action cable will only allow connections from localhost:3000 in development.** If you are going to something other than localhost:3000 you need to add something like this to your config:
60
-
61
- ```ruby
62
- # config/environments/development.rb
63
- Rails.application.configure do
64
- config.action_cable.allowed_request_origins = ['http://localhost:3000', 'http://localhost:5000']
65
- end
66
- ```
67
-
68
- #### 5 Try It Out
69
-
70
- If you don't already have a model to play with, add one now:
71
-
72
- `bundle exec rails generate model Word text:string`
73
-
74
- `bundle exec rake db:migrate`
75
-
76
- Move `app/models/word.rb` to `app/hyperloop/models/word.rb` and move
77
- `app/models/application_record.rb` to `app/hyperloop/models/application_record.rb`
78
-
79
- **Leave** `app/models/model.rb` where it is. This is your models client side manifest file.
80
-
81
- Whatever model(s) you will plan to access on the client need to moved to the `app/hyperloop/models` directory. This allows Hyperloop to build a client side proxy for the Models. Models not moved will be completely invisible on the client or in your Isomorphic code.
82
-
83
- **Important** in rails 5 there is also a base `ApplicationRecord` class, that all other models are built from. This class must be moved to `app/hyperloop/models` directory as well.
84
-
85
- If you don't already have a simple component to play with, here is a simple one (make sure you added the Word model):
86
-
87
- ```ruby
88
- # app/views/components/app.rb
89
- class App < Hyperloop::Component
90
-
91
- def add_new_word
92
- # for fun we will use setgetgo.com to get random words!
93
- HTTP.get("http://randomword.setgetgo.com/get.php", dataType: :jsonp) do |response|
94
- Word.new(text: response.json[:Word]).save
95
- end
96
- end
97
-
98
- render(DIV) do
99
- SPAN { "Count of Words: #{Word.count}" }
100
- BUTTON { "add another" }.on(:click) { add_new_word }
101
- UL do
102
- Word.each { |word| LI { word.text } }
103
- end
104
- end
105
- end
106
- ```
107
-
108
- Add a controller:
109
-
110
- ```ruby
111
- #app/controllers/test_controller.rb
112
- class TestController < ApplicationController
113
- def app
114
- render_component
115
- end
116
- end
117
- ```
118
-
119
- Add the `test` route to your routes file:
120
-
121
- ```ruby
122
- #app/config/routes.rb
123
-
124
- get 'test', to: 'test#app'
125
-
126
- ```
127
-
128
- Fire up rails with `bundle exec rails s` and open your app in a couple of browsers. As data changes you should see them all updating together.
129
-
130
- You can also fire up a rails console, and then for example do a `Word.new(text: "Hello").save` and again see any browsers updating.
131
-
132
- If you want to go into more details with the example check out [words-example](/docs/words-example.md)
133
-
134
- TODO check link above
@@ -1,275 +0,0 @@
1
- ## ActiveRecord API
2
-
3
- Hyperloop uses a subset of the standard ActiveRecord API to give your Isomorphic Components, Operations and Stores access to your server side Models. As much as possible Hyperloop follows the syntax and semantics of ActiveRecord.
4
-
5
- ### Interfacing to React
6
-
7
- Hyperloop integrates with React (through Components) to deliver your Model data to the client without you having to create extra APIs or specialized controllers. The key idea of React is that when state (or params) change, the portions of the display effected by this data will be updated.
8
-
9
- Hyperloop automatically creates React state objects that will be updated as server side data is loaded or changes. When these states change the associated parts of the display will be updated.
10
-
11
- A brief overview of how this works will help you understand the how Hypeloop gets the job done.
12
-
13
- #### Rendering Cycle
14
-
15
- On the UI you will be reading models in order to display data.
16
-
17
- If during the rendering of the display the Model data is not yet loaded, placeholder values (the default values from the `columns_hash`) will be returned by Hyperloop.
18
-
19
- Hyperloop then keeps track of where these placeholders (or `DummyValue`s) are displayed, and when they do get loaded, those parts of the display will re-render.
20
-
21
- If later the data changes (either due to local user actions, or receiving push updates) then again any parts of the display that were dependent on the current values will be re-rendered.
22
-
23
- You normally do not have to be aware of this. Just access your Models using the normal scopes and finders, then compute values and display attributes as you would on the server. Initially the display will show the placeholder values and then will be replaced with the real values.
24
-
25
- #### Prerendering
26
-
27
- During server-side pre-rendering, Hyperloop has direct access to the server so on initial page load all the values will be loaded and present.
28
-
29
- #### Lazy Loading
30
-
31
- Hyperloop lazy loads values, and does not load any thing until an explicit displayable value is requested. For example `Todo.all` will have no action, but `Todo.all.pluck[:title]` will return an array of titles.
32
-
33
- At the end of the rendering cycle the set of all values requested will be merged into a tree structure and sent to the server, returning the minimum amount of data needed.
34
-
35
- #### Load Cycle Methods
36
-
37
- TODO check link below
38
-
39
- There are a number of methods that allow you to interact with this load cycle when needed. These are documented [below](#other-methods-for-interacting-with-the-load-and-render-cycle).
40
-
41
- ### Class Methods
42
-
43
- #### New and Create
44
-
45
- `new`: Takes a hash of attributes and initializes a new unsaved record. The values of any attributes not specified in the hash will be taken from the Models default values specified in the `columns_hash`.
46
-
47
- If `new` is passed a native javascript object it will be treated as a hash and converted accordingly.
48
-
49
- `create`: Short hand for `new(...).save`. See the `save` instance method for details on how saving is done.
50
-
51
- #### Scoping and Finding
52
-
53
- `scope` and `default_scope`: Hyperloop adds four new options to these methods: `joins`, `client`, `select` and `server`. The `joins` option provides information on how the scope will be joined with other models. The `client` and `select` options allow scoping to be done on the client side to offload this from the server, and the `server` option is there just for symmetry with the other options. See the [Client Side Scoping](/docs/client_side_scoping.md) page for more details.
54
-
55
- TODO check link above
56
-
57
- ```ruby
58
- # the active scope proc is executed on the server
59
- scope :active, -> () { where(completed: true) }
60
-
61
- # if the scope does a join (or include) this must be indicated
62
- # using the joins: option.
63
- scope :with_recent_comments,
64
- -> { joins(:comments).where('comment.created_at >= ?', Time.now-1.week) },
65
- joins: ['comments'] # or joins: 'comments'
66
-
67
- # the server side proc can be indicated by the server: option
68
- # an optional client side proc can be provided to compute the scope
69
- # locally at the client
70
- scope :completed,
71
- server: -> { where(complete: true) }
72
- client: -> { complete } # return true if the record should be included
73
- ```
74
-
75
- `unscoped` and `all`: These builtin scopes work just like standard ActiveRecord.
76
-
77
- ```ruby
78
- Word.all.each { |word| LI { word.text }}
79
- ```
80
-
81
- BTW: to save typing you can skip the `all`: Models will respond like enumerators.
82
-
83
- `find`: takes an id and delivers the corresponding record.
84
-
85
- `find_by`: takes a single item hash indicating an attribute value pair to find.
86
-
87
- `find_by_...`: i.e. `find_by_first_name` these methods will find the first record with a matching attribute.
88
-
89
- ```ruby
90
- Word.find_by_text('hello') # short for Word.find_by(text: 'hello')
91
- ```
92
-
93
- `limit` and `offset`: These builtin scopes behave as they do on the server:
94
-
95
- ```ruby
96
- Word.offset(500).limit(20) # get words 500-519
97
- ```
98
-
99
- #### Relationships and Aggregations
100
-
101
- `belongs_to, has_many, has_one`: These all work as on the server. **However it is important that you fully specify both sides of the relationship.**
102
-
103
- ```ruby
104
- class Todo < ActiveRecord::Base
105
- belongs_to :assigned_to, class_name: 'User'
106
- end
107
-
108
- class User < ActiveRecord::Base
109
- has_many :todos, foreign_key: 'assigned_to_id'
110
- end
111
- ```
112
-
113
- Note that on the client the linkages between relationships are live and direct. In the above example this works:
114
-
115
- ```ruby
116
- Todo.create(assigned_to: some_user)
117
- ```
118
-
119
- but this may not:
120
-
121
- ```ruby
122
- Todo.create(assigned_to_id: some_user.id)
123
- ```
124
-
125
- `composed_of`: You can create aggregate models like ActiveRecord.
126
-
127
- Similar to the linkages in relationships, aggregate records are represented on the client as actual independent objects.
128
-
129
- #### Defining server methods
130
-
131
- Normally an application defined instance method will run on the client and the server:
132
-
133
- ```ruby
134
- class User < ActiveRecord::Base
135
- def full_name
136
- "#{first_name} #{last_name}"
137
- end
138
- end
139
- ```
140
-
141
- Sometimes it is desirable to only run the method on the server. This can be done using the `server_method` macro:
142
-
143
- ```ruby
144
- class User < ActiveRecord::Base
145
- server_method :full_name, default: '' do
146
- "#{first_name} #{last_name}"
147
- end
148
- end
149
- ```
150
-
151
- When the method is first called on the client the default value will be returned, and there will be a reactive update when the true value is returned from the server.
152
-
153
- To force the value to be recomputed at the server append a `!` to the end of the name, otherwise the last value returned from the server will continue to be returned.
154
-
155
- #### Model Information
156
-
157
- `column_names`: returns a list of the database columns.
158
-
159
- `columns_hash`: returns the details of the columns specification. Note that on the server `columns_hash` returns a hash of objects specifying column information. On the client the entire structure is just one big hash of hashes.
160
-
161
- `abstract_class=`, `abstract_class?`, `primary_key`, `primary_key=`, `inheritance_column`, `inheritance_column=`, `model_name`: All work as on the server. See ActiveRecord documentation for more info.
162
-
163
- ### Instance Methods
164
-
165
- #### Attribute and Relationship Getter and Setters
166
-
167
- All attributes have an associated getter and setter. All relationships have a getter. All `belongs_to` relationships also have a setter. `has_many` relationships can be updated using the push (`<<`) operator or using the `delete` method.
168
-
169
- ```ruby
170
- puts my_todo.title
171
- my_todo.title = "neutitle"
172
- my_todo.comments << a_new_comment
173
- a_new_comment.todo == my_todo # true!
174
- ```
175
-
176
- In addition if the attribute getter ends with a bang (!) then this will force a fetch of the attribute from the server. This is typically not necessary if push updates are configured.
177
-
178
- #### Saving
179
-
180
- The `save` method works like ActiveRecord save, *except* it returns a promise that is resolved when the save completes (or fails.)
181
-
182
- ```ruby
183
- my_todo.save(validate: false).then do |result|
184
- # result is a hash with {success: ..., message: , models: ....}
185
- end
186
- ```
187
-
188
- After a save operation completes the models will have an `errors` hash (just like on the server) with any validation problems.
189
-
190
- During the save operation the method `saving?` will return `true`. This can be used to instead of (or with) the promise to update the screen:
191
-
192
- ```ruby
193
- render do
194
- ...
195
- if some_model.saving?
196
- ... display please wait ...
197
- elsif some_model.errors.any?
198
- ... highlight the errors ...
199
- else
200
- ... display data ...
201
- end
202
- ...
203
- end
204
- ```
205
-
206
- #### Destroy
207
-
208
- Like `save` destroy returns a promise that is resolved when the destroy completes.
209
-
210
- After the destroy completes the record's `destroyed?` method will return true.
211
-
212
- #### Other Instance Methods
213
-
214
- `new?` returns true if the model is new and not yet saved.
215
-
216
- `primary_key` returns the primary key for the model
217
-
218
- `id` returns the value of the primary key for this instance
219
-
220
- `model_name` returns the model_name.
221
-
222
- `revert` Undoes any unsaved changes to the instance.
223
-
224
- `changed?` returns true if any attributes have changed (always true for a new model)
225
-
226
- `dup` duplicate the instance.
227
-
228
- `==` two instances are the same if it is known that they reference the same underlying table row.
229
-
230
- `..._changed?` (i.e. name_changed?) returns true if the specific attribute has changed.
231
-
232
- `itself` returns the record, but will override lazy loading and force a load of at least the model's id.
233
-
234
- ### Other Methods for Interacting with the Load and Render Cycle
235
-
236
- #### `loading?` and `loaded?`
237
-
238
- All Ruby objects will respond to these methods. If you want to put up a "Please Wait" message, spinner, etc, you can use the `loaded?` or `loading?` method to determine if the object represents a real loaded value or not. Any value for which `loaded?` returns `false` (or `loading?` returns `true`) will eventually load and cause a re-render
239
-
240
- TODO check below (was HyperMesh.load)
241
-
242
- #### The `HyperModel.load` Method
243
-
244
- Sometimes it is necessary to insure values are loaded outside of the rendering cycle. For this you can use the `HyperModel.load` method:
245
-
246
- ```ruby
247
- HyperModel.load do
248
- x = my_model.some_attribute
249
- OtherModel.find(x+12).other_attribute
250
- # code in here can be arbitrarily complex and load
251
- # will re-execute it until all values are loaded
252
- # the final expression is passed to the promise
253
- end.then |result|
254
- puts result
255
- end
256
- ```
257
-
258
- #### Force Loading Attributes
259
-
260
- Normally you will simply display attributes as part of the render method, and when the values are loaded from the server the component will re-render.
261
-
262
- Sometimes outside of the render method you may need to insure an attribute (or a server side method) is loaded before proceeding. This is typically when you are building some kind of higher level store.
263
-
264
- The `load` method takes a list of attributes (symbols) and will insure these are loaded. Load returns a promise that is resolved when the load completes, or can be passed a block that will execute when the load completes.
265
-
266
- ```ruby
267
- before_mount do
268
- Todo.find(1).load(:name).then do |name|
269
- @name = name;
270
- state.loaded! true
271
- end
272
- end
273
- ```
274
-
275
- Think hard about how you are using this, as Hyperloop already acts as flux store, and is managing state for you. It may be you are just creating a redundant store!
@@ -1,502 +0,0 @@
1
- ### Hyperloop Authorization Policies
2
-
3
- TODO: Move this doc to a Policy Section
4
-
5
- Access to your Isomorphic Models is controlled by *Policies* that describe how the current *acting_user* and *channels* may access your Models.
6
-
7
- Each browser session has an *acting_user* (which may be nil) and you will define `create`, `update`, and `destroy` policies giving (or denying) the `acting_user` the ability to do these operations.
8
-
9
- Read and *broadcast* access is defined based on *channels* which are connected based again on the current `acting_user`. Read access is initiated when a specific browser tries to read a record attribute, and broadcasts are initiated whenever a model changes.
10
-
11
- An application can have several channels and each channel and each active record model can have different policies to determine which attributes are sent when a record changes.
12
-
13
- For example a Todo application might have an *instance* of a channel for each currently logged in user; an instance of a channel for each team if that team has one or more logged in users; and a general `AdminUser` channel shared by all administrators that are logged in.
14
-
15
- Lets say a specific `Todo` changes, which is part of team id 123's Todo list, and users 7 and 8 who are members of that team are currently logged in as well as two of the `AdminUsers`.
16
-
17
- When the `Todo` changes we want all the attributes of the `Todo` broadcast on team 123's channel, as well on the `AdminUser`'s channel. Now lets say User 7 sends User 8 a private message, adding a new record to the `Message` model. This update should only be sent to user 7 and user 8's private channels, as well as to the AdminUser channel.
18
-
19
- We can define all these policies by creating the following classes:
20
-
21
- ```ruby
22
- class UserPolicy # defines policies for the User class
23
- # The regulate_instance_connections method enables instances of the User
24
- # class to be treated as a channel.
25
-
26
- # The policy is defined by a block that is executed in the context of the
27
- # current acting_user.
28
-
29
- # For our User instance connection the policy is that there must be a
30
- # logged-in user, and the connection is made to that user:
31
- regulate_instance_connections { self }
32
- # If there is no logged in user self will be nil, and no connection will be
33
- # made.
34
- end
35
-
36
- class TeamPolicy # defines policies for the Team class
37
- # Users can only connect to Teams that they belong to
38
- regulate_instance_connections { teams }
39
- end
40
-
41
- class AdminUserPolicy
42
- # All AdminUsers share the same connection so we setup a class wide
43
- # connection available to any users who are admins.
44
- regulate_class_connection { admin? }
45
-
46
- # The AdminUser channel will receive all attributes
47
- # of all records, unless the attribute is named :password
48
- regulate_all_broadcasts do |policy|
49
- policy.send_all_but(:password)
50
- end
51
- end
52
-
53
- class TodoPolicy
54
- # Policies can be established for models that are not channels as well.
55
-
56
- # The regulate_broadcast method will describe what attributes to send
57
- # when a Todo model changes.
58
-
59
- # The blocks of broadcast policies run in the context of the changed model
60
- # so we have access to all the models methods. In this case Todo
61
- # belongs to a Team through the 'team' relationship.
62
- regulate_broadcast do |policy|
63
- # send all Todo attributes to the todo's team channel
64
- policy.send_all.to(team)
65
- end
66
- end
67
-
68
- class MessagePolicy
69
- # Broadcast policies can be arbitrarily complex. In this case we
70
- # want to broadcast the entire message to the sender and the
71
- # recipient's instance channels.
72
- # In addition if the message is not private, then we want to send to all
73
- # the team instance channels that are shared between the sender and
74
- # recipient's teams.
75
- regulate_broadcast do |policy|
76
- policy.send_all.to(sender, recipient)
77
- policy.send_all.to(sender.teams.merge(recipient.teams)) unless private?
78
- end
79
- end
80
- ```
81
-
82
- Before we begin using these channels and policies we need to first define the Reactive-Record `acting_user` method in our ApplicationController:
83
-
84
- ```ruby
85
- class ApplicationController < ActionController::Base
86
- def acting_user
87
- # The acting_user method should return nil, or some object that corresponds to a
88
- # logged in user. Specifics will depend on your application and whatever other
89
- # authentication mechanisms you are using.
90
- @acting_user ||= session[:current_user_id] && User.find_by_id(session[:current_user_id])
91
- end
92
- end
93
- end
94
- ```
95
-
96
- Note that `acting_user` is also used by ReactiveRecord's permission system.
97
-
98
- Our entire set of policies is defined in 29 lines of code of which 8 actually execute the policies. Our existing classes form the foundation, and we simply add Hyperloop specific policy directives. Pretty sweet huh?
99
-
100
- ### Details
101
-
102
- Hyperloop uses *Policies* to *regulate* what *connections* are opened between clients and the server and what data is distributed over those connections.
103
-
104
- Connections are made on *channels* of data flowing between the server and a number of clients. Each channel is associated with either a class or an instance of a class. Typically the channel class represents an entity (or is associated with an entity) that can be authenticated like a `User`, an `AdminUser`, or a `Team` of users. A channel associated with the class itself broadcasts data that is received by any member of that class. A channel associated with an instance is for data that is available only to that specific instance.
105
-
106
- As Models on the server change (i.e. created, updated, or destroyed) the changes are broadcast over open channels. What specific attributes are sent (if any) is determined by broadcast policies.
107
-
108
- Broadcast policies can be associated with Models. As the Model changes the broadcast policy will regulate what attributes of the changed model will be sent over which channels.
109
-
110
- Broadcast policies can also be associated with a channel and will regulate *all* model changes over specific channels. In other words this is just a convenient way to associate a common policy with *all* Models.
111
-
112
- Note that Models that are associated with channels can also broadcast their changes on the same or different channels.
113
-
114
- #### Defining Policies and Policy Classes
115
-
116
- The best way to define policies is to use a *Policy Class*. A policy class has the same class name as the class it is regulating, with `Policy` added to the end. Policy classes are compatible with `Pundit`, and you can add regular pundit policies as well.
117
-
118
- Policies are defined using four methods:
119
- + `regulate_class_connection` controls connections to the class channels,
120
- + `regulate_instance_connections` controls connections to instance channels,
121
- + `regulate_broadcast` controls what data will be sent when a model or object changes and,
122
- + `regulate_all_broadcasts` controls what data will be sent of some channels when any model changes.
123
-
124
- In addition `always_allow_connection` is short hand for `regulate_class_connection { true }`
125
-
126
- A policy class can be defined for which there is no regulated class. This is useful for application wide connections, which are typically open even if no one is logged in:
127
-
128
- ```ruby
129
- #app/policies/application.rb
130
- class ApplicationPolicy
131
- regulate_class_connection { true }
132
- end
133
- ```
134
-
135
- Note that by default policy classes go in the `app/policies` directory. Hyperloop will require all the files in this directory.
136
-
137
- TODO check the name of the module below
138
-
139
- If you wish, you can also add policies directly in your Models by including the `Hyperloop::PolicyMethods` module in your model. You can then use the `regulate_class_connection`, `regulate_instance_connections`, `regulate_all_broadcasts` and `regulate_broadcast` methods directly in the model.
140
-
141
- ```ruby
142
- class User < ActiveRecord::Base
143
- include Hyperloop::PolicyMethods
144
- regulate_class_connection ...
145
- regulate_instance_connections ...
146
- regulate_all_broadcasts ...
147
- regulate_broadcast ...
148
- end
149
- ```
150
-
151
- Normally the policy methods are regulating the class with the prefix as the policy, but you can override this by providing specific class names to the policy method. This allows you to group several different class policies together, and to reuse policies:
152
-
153
- ```ruby
154
- class ApplicationPolicy
155
- regulate_connection { ... } # Application is assumed
156
- regulate_class_connection(User) { ... }
157
- # regulate_class_connection, regulate_instance_connections and
158
- # regulate_all_broadcasts can take a list of channels.
159
- regulate_all_broadcasts(User, Application)
160
- # regulate_broadcast takes a list of object classes which
161
- # may also be channels.
162
- regulate_broadcast(Todo, Message, User) { ... }
163
- end
164
- ```
165
-
166
- #### Channels and the connection policies
167
-
168
- Any ruby class that has a connection policy is a Hyperloop channel. The fully scoped name of the class becomes the root of the channel name.
169
-
170
- The purpose of having channels is to restrict what gets broadcast when models change, therefore typically channels represent *connections* to
171
-
172
- + the application, or some function within the application
173
- + or some class which is *authenticated* like a User or Administrator,
174
- + instances of those classes,
175
- + or instances of related classes.
176
-
177
- So a channel that is connected to the User class would get information readable by any logged-in user, while a channel that is connected to a specific User instance would get information readable by that specific user.
178
-
179
- The `regulate_class_connection` takes a block that will execute in the context of the current acting_user (which may be nil), and if the block returns any truthy value, the connection will be made.
180
-
181
- The `regulate_instance_connections` likewise takes a block that is executed in the context of the current acting_user. The block may do one of following:
182
-
183
- + raise an error meaning the connection cannot be made,
184
- + return a falsy value also meaning the connection cannot be made,
185
- + return a single object meaning the connection can be made to that object,
186
- + return a enumerable of objects meaning the connection can made to any member of the enumerable.
187
-
188
- Note that the object (or objects) returned are expected to be of the same class as the regulated policy.
189
-
190
- ```ruby
191
- # Create a class connection only if the acting_user is non-nil (i.e. logged in:)
192
- regulate_class_connection { self }
193
- # Always open the connection:
194
- regulate_class_connection { true }
195
- # Which can be shortened to:
196
- always_allow_connection
197
- # Create a class level connection if the acting_user is an admin:
198
- regulate_class_connection { admin? }
199
- # Create an instance connection for the current user:
200
- regulate_instance_connections { self }
201
- # Create an instance connection for the current user if the user is an admin:
202
- regulate_instance_connections { self if admin? }
203
- # create an instance_connection to the users' group
204
- regulate_instance_connections { group }
205
- # create an instance connection for any team the user belongs to
206
- regulate_instance_connections { teams }
207
- ```
208
-
209
- #### Class Names, Instances and IDs
210
-
211
- While establishing connections, classes are represented as their fully scoped name, and instances are represented as the class name plus the result of calling `id` on the instance.
212
-
213
- Typically connections are made to ActiveRecord models, and if those are in the `app/hyperloop/models` folder everything will work fine.
214
-
215
- #### Acting User
216
-
217
- Hyperloop looks for an `acting_user` method typically defined in the ApplicationController and would normally pick up the current session user, and return an appropriate object.
218
-
219
- ```ruby
220
- class ApplicationController < ActiveController::Base
221
- def acting_user
222
- @acting_user ||= session[:current_user_id] && User.find_by_id(session[:current_user_id])
223
- end
224
- end
225
- end
226
- ```
227
-
228
- #### Automatic Connection
229
-
230
- Connections to channels available to the current `acting_user` are automatically made on the initial page load. This behavior can be turned off with the `auto_connect` option.
231
-
232
- ```ruby
233
- class TeamPolicy
234
- # Allow current users to establish connections to any teams they are
235
- # members of, but disable_auto_connect
236
- regulate_instance_connections(auto_connect: false) { teams }
237
- end
238
- ```
239
-
240
- Its important to consider turning off automatic connections for cases like the above where
241
- the user is likely to be a member of many teams. Typically the client application will
242
- want to dynamically determine which specific teams to connect to given the current state of
243
- the application.
244
-
245
- ### Manually Connecting to Channels
246
-
247
- Normally the client will automatically connect to the available channels when a page loads, but you can also
248
- manually connect on the client in response to some user action like logging in, or the user deciding to
249
- display a specific team status on their dashboard.
250
-
251
- TODO check below Hyperloop.connect
252
-
253
- To manually connect a client use the `Hyperloop.connect` method.
254
-
255
- The `connect` method takes any number of arguments each of which is either a class, an object, a String or Array.
256
-
257
- If the argument is a class then the connection will be made to the matching class channel on the server.
258
-
259
- ```ruby
260
- # connect the client to the AdminUser class channel
261
- Hyperloop.connect(AdminUser)
262
- # if the connection is successful the client will begin getting updates on the
263
- # AdminUser class channel
264
- ```
265
-
266
- If the argument is an object then a connection will be made to the matching object on the server.
267
-
268
- ```ruby
269
- # assume current_user is an instance of class User
270
- Hyperloop.connect(current_user)
271
- # current_user.id is used to establish which User instance to connect to on the
272
- # server
273
- ```
274
-
275
- The argument can also be a string, which matches the name of a class on the server
276
-
277
- ```ruby
278
- Hyperloop.connect('AdminUser')
279
- # same as AdminUser class
280
- ```
281
-
282
- or the argument can be an array with a string and the id:
283
-
284
- ```ruby
285
- Hyperloop.connect(['User', current_user.id])
286
- # same as saying current_user
287
- ```
288
-
289
- You can make several connections at once as well:
290
- ```ruby
291
- Hyperloop.connect(AdminUser, current_user)
292
- ```
293
-
294
- Finally falsy values are ignored.
295
-
296
- You can also send `connect` directly to ActiveRecord models:
297
-
298
- ```ruby
299
- AdminUser.connect! # same as Hyperloop.connect(AdminUser)
300
- current_user.connect! # same as Hyperloop.connect(current_user)
301
- ```
302
-
303
- #### Connection Sequence Summary
304
-
305
- For class connections:
306
-
307
- 1. The client calls `Hyperloop.connect`.
308
- 2. Hyperloop sends the channel name to the server.
309
- 3. Hyperloop has its own controller which will determine the `acting_user`,
310
- 4. and call the channel's `regulate_class_connection` method.
311
- 5. If `regulate_class_connection` returns a truthy value then the connection is made,
312
- 6. otherwise a 500 error is returned.
313
-
314
- For instance connections:
315
-
316
- 1. The process is the same but the channel name and id are sent to the server.
317
- 2. The Hyperloop controller will do a `find` of the id passed to get the instance,
318
- 3. and if successful `regulate_instance_connections` is called,
319
- 4. which must return an either the same instance, or an enumerable with that instance as a member.
320
- 5. Otherwise a 500 error is returned.
321
-
322
- Note that the same sequence is used for auto connections and manually invoked connections.
323
-
324
- #### Disconnecting
325
-
326
- TODO check Hyperloop.disconnect(
327
-
328
- Calling `Hyperloop.disconnect(channel)` or `channel.disconnect!` will disconnect from the channel.
329
-
330
- #### Broadcasting and Broadcast Policies
331
-
332
- Broadcast policies can be defined for channels using the `regulate_all_broadcasts` method, and for individual objects (typically ActiveRecord models) using the `regulate_broadcast` method. A `regulate_all_broadcasts` policy is essentially a `regulate_broadcast` that will be run for every record that changes in the system.
333
-
334
- After an ActiveRecord Model change is committed, all active class channels run their channel broadcast policies, and then the instance broadcast policy associated with the changing Model is run. So for any change there may be multiple channel broadcast policies involved, but only one (at most) regulate_broadcast.
335
-
336
- The result is that each channel may get a filtered copy of the record which is broadcast on that channel.
337
-
338
- The purpose of the policies then is to determine which channel sees what. Each broadcast policy receives the instance of the policy which responds to the following methods
339
-
340
- + `send_all`: send all the attributes of the record.
341
- + `send_only`: send only the listed attributes of the record.
342
- + `send_all_but`: send all the attributes except the ones listed.
343
-
344
- The result of the `send...` method is then directed to the set of channels using the `to` method:
345
-
346
- ```ruby
347
- policy.send_all_but(:password).to(AdminUser)
348
- ```
349
-
350
- Within channel broadcast policies the channel is assumed to be the channel in question:
351
-
352
- ```ruby
353
- class AdminUserPolicy
354
- regulate_all_broadcasts do |policy|
355
- policy.send_all_but(:password) #.to(AdminUser) is not needed.
356
- end
357
- end
358
- ```
359
-
360
- The `to` method can take any number of arguments:
361
-
362
- + a class naming a channel,
363
- + an object that is instance channel,
364
- + an ActiveRecord collection,
365
- + any falsy value which will be ignored,
366
- + or an array that will be flattened and merged with the other arguments.
367
-
368
- The broadcast policy executes in the context of the model that has just changed, so the policy can use all the methods of that model, especially relationships. For example:
369
-
370
- ```ruby
371
- class Message < ActiveRecord::Base
372
- belongs_to :sender, class: "User"
373
- belongs_to :recipient, class: "User"
374
- end
375
-
376
- class MessagePolicy
377
- regulate_broadcast do |policy|
378
- # send all attributes to both the sender, and recipient User instance channels
379
- policy.send_all.to(sender, recipient)
380
- # send all attributes to intersection
381
- policy.send_all.to(sender.teams.merge(recipient.teams)) unless private?
382
- end
383
- end
384
- ```
385
-
386
- It is possible that the same channel may be sent a record from different policies, in this case the minimum set of attributes will be sent regardless of the order of the send operations. For example:
387
-
388
- ```ruby
389
- policy.send_all_but(:password).to(MyChannel)
390
- # ... later
391
- policy.send_all.to(MyChannel)
392
- # MyChannel gets everything but the password
393
- ```
394
-
395
- or even
396
-
397
- ```ruby
398
- policy.send_only(:foo, :bar).to(MyChannel)
399
- policy.send_only(:baz).to(MyChannel)
400
- # MyChannel gets nothing
401
- ```
402
-
403
- Keep in mind that the broadcast policies are sent a copy of the policy object so you can use helper methods in your policies. Also you can add policy specific methods to your models using
404
- `class_eval` thus keeping policy logic out of your models.
405
-
406
- So we could for example we can rewrite the above MessagePolicy like this:
407
-
408
- ```ruby
409
- class MessagePolicy
410
- Message.class_eval do
411
- scope :teams_for_policy, -> () { sender.teams.merge(recipient.teams) }
412
- end
413
- def teams # the obj method returns the instance being regulated
414
- [obj.sender, obj.recipient, !obj.private? && obj.teams_for_policy]
415
- end
416
- regulate_broadcast { |policy| policy.send_all.to(policy.teams) }
417
- end
418
- ```
419
-
420
- #### Browser Initiated Change policies
421
-
422
- To allow code in the browser to create, update or destroy a model, there must be a change access policy defined for that operation.
423
-
424
- Each change access policy executes a block in the context of the record that will be accessed. The current value of `acting_user` is also defined for the life of the block.
425
-
426
- If the block returns a truthy value access will be allowed, otherwise if the block returns a falsy value or raises an exception, access will be denied.
427
-
428
- In the below examples we assume that your user model responds to `admin?` but this is not built into Hyperloop.
429
-
430
- ```ruby
431
- class TodoPolicy
432
- # allow creation to any logged in user
433
- allow_create { acting_user }
434
- # only allow the owner, author any any admin to update a todo
435
- allow_update { acting_user == owner || acting_user == author || acting_user.admin? }
436
- # don't allow Todo's to be destroyed
437
- # this is the default behavior so its not actually needed
438
- allow_destroy { false }
439
- end
440
- ```
441
-
442
- There are several variants of the access policy method:
443
-
444
- ```ruby
445
- class ConfigDataPolicy
446
- allow_change(on: [:create, :update, :destroy]) { acting_user.admin? }
447
- # which can be shortened to:
448
- allow_change { acting_user.admin? }
449
- end
450
- ```
451
-
452
- ```ruby
453
- class ApplicationPolicy
454
- # do any thing to all models unless we are in production! Be careful!
455
- allow_change(to: :all) { true } unless Rails.env.production?
456
- # and always allow admins to destroy models globally:
457
- allow_change(to: :all, on: :destroy) { acting_user.admin? }
458
- # which is the same as saying:
459
- allow_destroy(to: :all) { acting_user.admin? }
460
- # you can create model specific policies in the Application Policy as well.
461
- # Here we allow the author of a message to destroy the message within 5
462
- # minutes of creation.
463
- allow_destroy(to: Message) do
464
- return true if acting_user == author && created_at > 5.minutes.ago
465
- return true if acting_user.admin?
466
- end
467
- end
468
- ```
469
-
470
- Note that there is no `allow_read` method. Read access is granted if this browser would have the attribute broadcast to it.
471
-
472
-
473
- #### Method Summary and Name Space Conflicts
474
-
475
- Policy classes (and the Hyperloop::PolicyMethods module) define the following class methods:
476
-
477
- + `regulate_connection`
478
- + `regulate_all_broadcasts`
479
- + `regulate_broadcast`
480
-
481
- As well as the following instance methods:
482
- + `send_all`
483
- + `send_all_but`
484
- + `send_only`
485
- + `obj`
486
-
487
- TODO check `synchromesh_internal_policy_object` new name
488
-
489
- To avoid name space conflicts with your classes, Hyperloop policy classes (and the Hyperloop::PolicyMethods module) maintain class and instance `attr_accessor`s named `synchromesh_internal_policy_object`. The above methods call methods of the same name in the appropriate internal policy object.
490
-
491
- You may thus freely redefine of the class and instance methods if you have name space conflicts
492
-
493
- ```ruby
494
- class ProductionCenterPolicy < MyPolicyClass
495
- # MyPolicyClass already defines our version of obj
496
- # so we will call it 'this'
497
- def this
498
- synchromesh_internal_policy_object.obj
499
- end
500
- ...
501
- end
502
- ```