hyper-mesh 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/.rubocop.yml +11 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +396 -0
- data/Rakefile +6 -0
- data/app/controllers/reactive_record/application_controller.rb +4 -0
- data/app/controllers/reactive_record/reactive_record_controller.rb +49 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/codeship.database.yml +18 -0
- data/config/routes.rb +7 -0
- data/docs/action_cable_quickstart.md +151 -0
- data/docs/authorization-policies.md +449 -0
- data/docs/client_side_scoping.md +103 -0
- data/docs/pusher_quickstart.md +0 -0
- data/docs/simple_poller_quickstart.md +121 -0
- data/docs/todo-example.md +116 -0
- data/docs/words-example.md +65 -0
- data/examples/action-cable/.gitignore +21 -0
- data/examples/action-cable/Gemfile +58 -0
- data/examples/action-cable/Gemfile.lock +247 -0
- data/examples/action-cable/README.md +24 -0
- data/examples/action-cable/Rakefile +6 -0
- data/examples/action-cable/app/assets/config/manifest.js +3 -0
- data/examples/action-cable/app/assets/javascripts/application.js +18 -0
- data/examples/action-cable/app/assets/stylesheets/application.css +15 -0
- data/examples/action-cable/app/controllers/application_controller.rb +3 -0
- data/examples/action-cable/app/controllers/test_controller.rb +6 -0
- data/examples/action-cable/app/models/models.rb +2 -0
- data/examples/action-cable/app/models/public/application_record.rb +3 -0
- data/examples/action-cable/app/models/public/word.rb +2 -0
- data/examples/action-cable/app/policies/application_policy.rb +6 -0
- data/examples/action-cable/app/views/components.rb +17 -0
- data/examples/action-cable/app/views/components/app.rb +18 -0
- data/examples/action-cable/app/views/layouts/application.html.erb +14 -0
- data/examples/action-cable/app/views/layouts/mailer.html.erb +13 -0
- data/examples/action-cable/app/views/layouts/mailer.text.erb +1 -0
- data/examples/action-cable/bin/bundle +3 -0
- data/examples/action-cable/bin/rails +9 -0
- data/examples/action-cable/bin/rake +9 -0
- data/examples/action-cable/bin/setup +34 -0
- data/examples/action-cable/bin/spring +15 -0
- data/examples/action-cable/bin/update +29 -0
- data/examples/action-cable/config.ru +5 -0
- data/examples/action-cable/config/application.rb +30 -0
- data/examples/action-cable/config/boot.rb +3 -0
- data/examples/action-cable/config/cable.yml +9 -0
- data/examples/action-cable/config/database.yml +25 -0
- data/examples/action-cable/config/environment.rb +5 -0
- data/examples/action-cable/config/environments/development.rb +45 -0
- data/examples/action-cable/config/environments/production.rb +86 -0
- data/examples/action-cable/config/environments/test.rb +42 -0
- data/examples/action-cable/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/action-cable/config/initializers/assets.rb +11 -0
- data/examples/action-cable/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/action-cable/config/initializers/cookies_serializer.rb +5 -0
- data/examples/action-cable/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/action-cable/config/initializers/inflections.rb +16 -0
- data/examples/action-cable/config/initializers/mime_types.rb +4 -0
- data/examples/action-cable/config/initializers/new_framework_defaults.rb +24 -0
- data/examples/action-cable/config/initializers/session_store.rb +3 -0
- data/examples/action-cable/config/initializers/synchromesh.rb +5 -0
- data/examples/action-cable/config/initializers/wrap_parameters.rb +14 -0
- data/examples/action-cable/config/locales/en.yml +23 -0
- data/examples/action-cable/config/puma.rb +47 -0
- data/examples/action-cable/config/routes.rb +5 -0
- data/examples/action-cable/config/secrets.yml +22 -0
- data/examples/action-cable/config/spring.rb +6 -0
- data/examples/action-cable/db/migrate/20160921223808_create_words.rb +9 -0
- data/examples/action-cable/db/schema.rb +21 -0
- data/examples/action-cable/log/.keep +0 -0
- data/examples/action-cable/public/404.html +67 -0
- data/examples/action-cable/public/422.html +67 -0
- data/examples/action-cable/public/500.html +66 -0
- data/examples/action-cable/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/action-cable/public/apple-touch-icon.png +0 -0
- data/examples/action-cable/public/favicon.ico +0 -0
- data/examples/action-cable/public/robots.txt +5 -0
- data/examples/action-cable/rails_cache_dir2/C91/480/synchromesh_active_connections +0 -0
- data/examples/action-cable/tmp/.keep +0 -0
- data/examples/action-cable/vendor/assets/javascripts/.keep +0 -0
- data/examples/action-cable/vendor/assets/stylesheets/.keep +0 -0
- data/examples/simple-poller/.gitignore +21 -0
- data/examples/simple-poller/Gemfile +64 -0
- data/examples/simple-poller/Gemfile.lock +272 -0
- data/examples/simple-poller/README.md +24 -0
- data/examples/simple-poller/Rakefile +6 -0
- data/examples/simple-poller/app/assets/config/manifest.js +3 -0
- data/examples/simple-poller/app/assets/images/.keep +0 -0
- data/examples/simple-poller/app/assets/javascripts/application.js +20 -0
- data/examples/simple-poller/app/assets/javascripts/channels/.keep +0 -0
- data/examples/simple-poller/app/assets/stylesheets/application.css +15 -0
- data/examples/simple-poller/app/channels/application_cable/channel.rb +4 -0
- data/examples/simple-poller/app/channels/application_cable/connection.rb +4 -0
- data/examples/simple-poller/app/controllers/application_controller.rb +3 -0
- data/examples/simple-poller/app/controllers/concerns/.keep +0 -0
- data/examples/simple-poller/app/controllers/test_controller.rb +6 -0
- data/examples/simple-poller/app/helpers/application_helper.rb +2 -0
- data/examples/simple-poller/app/jobs/application_job.rb +2 -0
- data/examples/simple-poller/app/mailers/application_mailer.rb +4 -0
- data/examples/simple-poller/app/models/concerns/.keep +0 -0
- data/examples/simple-poller/app/models/models.rb +2 -0
- data/examples/simple-poller/app/models/public/.keep +0 -0
- data/examples/simple-poller/app/models/public/application_record.rb +3 -0
- data/examples/simple-poller/app/models/public/word.rb +2 -0
- data/examples/simple-poller/app/policies/application_policy.rb +5 -0
- data/examples/simple-poller/app/views/components.rb +18 -0
- data/examples/simple-poller/app/views/components/.keep +0 -0
- data/examples/simple-poller/app/views/components/app.rb +40 -0
- data/examples/simple-poller/app/views/layouts/application.html.erb +14 -0
- data/examples/simple-poller/app/views/layouts/mailer.html.erb +13 -0
- data/examples/simple-poller/app/views/layouts/mailer.text.erb +1 -0
- data/examples/simple-poller/bin/bundle +3 -0
- data/examples/simple-poller/bin/rails +9 -0
- data/examples/simple-poller/bin/rake +9 -0
- data/examples/simple-poller/bin/setup +34 -0
- data/examples/simple-poller/bin/spring +16 -0
- data/examples/simple-poller/bin/update +29 -0
- data/examples/simple-poller/config.ru +5 -0
- data/examples/simple-poller/config/application.rb +20 -0
- data/examples/simple-poller/config/boot.rb +3 -0
- data/examples/simple-poller/config/cable.yml +9 -0
- data/examples/simple-poller/config/database.yml +25 -0
- data/examples/simple-poller/config/environment.rb +5 -0
- data/examples/simple-poller/config/environments/development.rb +44 -0
- data/examples/simple-poller/config/environments/production.rb +86 -0
- data/examples/simple-poller/config/environments/test.rb +42 -0
- data/examples/simple-poller/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/simple-poller/config/initializers/assets.rb +11 -0
- data/examples/simple-poller/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/simple-poller/config/initializers/cookies_serializer.rb +5 -0
- data/examples/simple-poller/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/simple-poller/config/initializers/inflections.rb +16 -0
- data/examples/simple-poller/config/initializers/mime_types.rb +4 -0
- data/examples/simple-poller/config/initializers/new_framework_defaults.rb +24 -0
- data/examples/simple-poller/config/initializers/session_store.rb +3 -0
- data/examples/simple-poller/config/initializers/synchromesh.rb +15 -0
- data/examples/simple-poller/config/initializers/wrap_parameters.rb +14 -0
- data/examples/simple-poller/config/locales/en.yml +23 -0
- data/examples/simple-poller/config/puma.rb +47 -0
- data/examples/simple-poller/config/routes.rb +5 -0
- data/examples/simple-poller/config/secrets.yml +22 -0
- data/examples/simple-poller/config/spring.rb +6 -0
- data/examples/simple-poller/db/migrate/20161013220135_create_words.rb +9 -0
- data/examples/simple-poller/db/schema.rb +21 -0
- data/examples/simple-poller/db/seeds.rb +7 -0
- data/examples/simple-poller/lib/assets/.keep +0 -0
- data/examples/simple-poller/lib/tasks/.keep +0 -0
- data/examples/simple-poller/log/.keep +0 -0
- data/examples/simple-poller/public/404.html +67 -0
- data/examples/simple-poller/public/422.html +67 -0
- data/examples/simple-poller/public/500.html +66 -0
- data/examples/simple-poller/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/simple-poller/public/apple-touch-icon.png +0 -0
- data/examples/simple-poller/public/favicon.ico +0 -0
- data/examples/simple-poller/public/robots.txt +5 -0
- data/examples/simple-poller/test/controllers/.keep +0 -0
- data/examples/simple-poller/test/fixtures/.keep +0 -0
- data/examples/simple-poller/test/fixtures/files/.keep +0 -0
- data/examples/simple-poller/test/fixtures/words.yml +7 -0
- data/examples/simple-poller/test/helpers/.keep +0 -0
- data/examples/simple-poller/test/integration/.keep +0 -0
- data/examples/simple-poller/test/mailers/.keep +0 -0
- data/examples/simple-poller/test/models/.keep +0 -0
- data/examples/simple-poller/test/models/word_test.rb +7 -0
- data/examples/simple-poller/test/test_helper.rb +10 -0
- data/examples/simple-poller/tmp/.keep +0 -0
- data/examples/simple-poller/vendor/assets/javascripts/.keep +0 -0
- data/examples/simple-poller/vendor/assets/stylesheets/.keep +0 -0
- data/examples/words/.gitignore +21 -0
- data/examples/words/Gemfile +58 -0
- data/examples/words/Gemfile.lock +247 -0
- data/examples/words/README.md +24 -0
- data/examples/words/Rakefile +6 -0
- data/examples/words/app/assets/config/manifest.js +3 -0
- data/examples/words/app/assets/javascripts/application.js +18 -0
- data/examples/words/app/assets/stylesheets/application.css +15 -0
- data/examples/words/app/controllers/application_controller.rb +3 -0
- data/examples/words/app/controllers/test_controller.rb +6 -0
- data/examples/words/app/models/models.rb +2 -0
- data/examples/words/app/models/public/application_record.rb +3 -0
- data/examples/words/app/models/public/word.rb +10 -0
- data/examples/words/app/policies/application_policy.rb +6 -0
- data/examples/words/app/views/components.rb +16 -0
- data/examples/words/app/views/components/app.rb +31 -0
- data/examples/words/app/views/layouts/application.html.erb +14 -0
- data/examples/words/app/views/layouts/mailer.html.erb +13 -0
- data/examples/words/app/views/layouts/mailer.text.erb +1 -0
- data/examples/words/bin/bundle +3 -0
- data/examples/words/bin/rails +9 -0
- data/examples/words/bin/rake +9 -0
- data/examples/words/bin/setup +34 -0
- data/examples/words/bin/spring +15 -0
- data/examples/words/bin/update +29 -0
- data/examples/words/config.ru +5 -0
- data/examples/words/config/application.rb +30 -0
- data/examples/words/config/boot.rb +3 -0
- data/examples/words/config/cable.yml +9 -0
- data/examples/words/config/database.yml +25 -0
- data/examples/words/config/environment.rb +5 -0
- data/examples/words/config/environments/development.rb +45 -0
- data/examples/words/config/environments/production.rb +86 -0
- data/examples/words/config/environments/test.rb +42 -0
- data/examples/words/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/words/config/initializers/assets.rb +11 -0
- data/examples/words/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/words/config/initializers/cookies_serializer.rb +5 -0
- data/examples/words/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/words/config/initializers/inflections.rb +16 -0
- data/examples/words/config/initializers/mime_types.rb +4 -0
- data/examples/words/config/initializers/new_framework_defaults.rb +24 -0
- data/examples/words/config/initializers/session_store.rb +3 -0
- data/examples/words/config/initializers/synchromesh.rb +5 -0
- data/examples/words/config/initializers/wrap_parameters.rb +14 -0
- data/examples/words/config/locales/en.yml +23 -0
- data/examples/words/config/puma.rb +47 -0
- data/examples/words/config/routes.rb +5 -0
- data/examples/words/config/secrets.yml +22 -0
- data/examples/words/config/spring.rb +6 -0
- data/examples/words/db/migrate/20160921223808_create_words.rb +9 -0
- data/examples/words/db/schema.rb +28 -0
- data/examples/words/log/.keep +0 -0
- data/examples/words/public/404.html +67 -0
- data/examples/words/public/422.html +67 -0
- data/examples/words/public/500.html +66 -0
- data/examples/words/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/words/public/apple-touch-icon.png +0 -0
- data/examples/words/public/favicon.ico +0 -0
- data/examples/words/public/robots.txt +5 -0
- data/examples/words/tmp/.keep +0 -0
- data/examples/words/vendor/assets/javascripts/.keep +0 -0
- data/examples/words/vendor/assets/stylesheets/.keep +0 -0
- data/hyper-mesh.gemspec +82 -0
- data/lib/active_record_base.rb +152 -0
- data/lib/enumerable/pluck.rb +6 -0
- data/lib/hyper-mesh.rb +62 -0
- data/lib/hypermesh/version.rb +3 -0
- data/lib/opal/equality_patches.rb +15 -0
- data/lib/opal/parse_patch.rb +14 -0
- data/lib/opal/set_patches.rb +8 -0
- data/lib/reactive_record/active_record/aggregations.rb +69 -0
- data/lib/reactive_record/active_record/associations.rb +111 -0
- data/lib/reactive_record/active_record/base.rb +9 -0
- data/lib/reactive_record/active_record/class_methods.rb +177 -0
- data/lib/reactive_record/active_record/error.rb +26 -0
- data/lib/reactive_record/active_record/instance_methods.rb +129 -0
- data/lib/reactive_record/active_record/public_columns_hash.rb +19 -0
- data/lib/reactive_record/active_record/reactive_record/base.rb +520 -0
- data/lib/reactive_record/active_record/reactive_record/collection.rb +517 -0
- data/lib/reactive_record/active_record/reactive_record/column_types.rb +67 -0
- data/lib/reactive_record/active_record/reactive_record/dummy_value.rb +218 -0
- data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +532 -0
- data/lib/reactive_record/active_record/reactive_record/reactive_set_relationship_helpers.rb +189 -0
- data/lib/reactive_record/active_record/reactive_record/scoped_collection.rb +62 -0
- data/lib/reactive_record/active_record/reactive_record/unscoped_collection.rb +16 -0
- data/lib/reactive_record/active_record/reactive_record/while_loading.rb +299 -0
- data/lib/reactive_record/engine.rb +13 -0
- data/lib/reactive_record/interval.rb +190 -0
- data/lib/reactive_record/permissions.rb +102 -0
- data/lib/reactive_record/pry.rb +13 -0
- data/lib/reactive_record/reactive_scope.rb +18 -0
- data/lib/reactive_record/scope_description.rb +108 -0
- data/lib/reactive_record/serializers.rb +7 -0
- data/lib/reactive_record/server_data_cache.rb +347 -0
- data/lib/reactive_record/version.rb +3 -0
- data/lib/sources/hyper-mesh/pusher.js +98 -0
- data/lib/synchromesh/action_cable.rb +39 -0
- data/lib/synchromesh/client_drivers.rb +357 -0
- data/lib/synchromesh/configuration.rb +40 -0
- data/lib/synchromesh/connection.rb +144 -0
- data/lib/synchromesh/policy.rb +504 -0
- data/lib/synchromesh/reactive_record/permission_patches.rb +43 -0
- data/lib/synchromesh/synchromesh.rb +155 -0
- data/lib/synchromesh/synchromesh_controller.rb +154 -0
- data/logo.jpg +0 -0
- data/path_release_steps.md +0 -0
- data/reactive_record_test_app/Gemfile +15 -0
- data/reactive_record_test_app/Gemfile.lock +209 -0
- data/reactive_record_test_app/README.rdoc +261 -0
- data/reactive_record_test_app/Rakefile +7 -0
- data/reactive_record_test_app/app/assets/javascripts/application.rb +5 -0
- data/reactive_record_test_app/app/assets/javascripts/components/another_component.rb +24 -0
- data/reactive_record_test_app/app/assets/javascripts/components/empty_component.rb +6 -0
- data/reactive_record_test_app/app/assets/javascripts/components/todo_item_component.js.rb +16 -0
- data/reactive_record_test_app/app/assets/javascripts/components/todos_component.js.rb +42 -0
- data/reactive_record_test_app/app/assets/javascripts/components/todos_main_component.rb +49 -0
- data/reactive_record_test_app/app/assets/javascripts/react_js_test_only.js +21618 -0
- data/reactive_record_test_app/app/assets/javascripts/reactive_record_config.js +2 -0
- data/reactive_record_test_app/app/assets/javascripts/spec/reactive_record_xspec.js.rb +42 -0
- data/reactive_record_test_app/app/assets/stylesheets/application.css +13 -0
- data/reactive_record_test_app/app/controllers/application_controller.rb +8 -0
- data/reactive_record_test_app/app/controllers/home_controller.rb +7 -0
- data/reactive_record_test_app/app/controllers/test_controller.rb +7 -0
- data/reactive_record_test_app/app/helpers/application_helper.rb +2 -0
- data/reactive_record_test_app/app/mailers/.gitkeep +0 -0
- data/reactive_record_test_app/app/models/.gitkeep +0 -0
- data/reactive_record_test_app/app/policies/application_policy.rb +5 -0
- data/reactive_record_test_app/app/views/components.rb +4 -0
- data/reactive_record_test_app/app/views/components/test.rb +18 -0
- data/reactive_record_test_app/app/views/home/index.html.erb +1 -0
- data/reactive_record_test_app/app/views/layouts/application.html.erb +17 -0
- data/reactive_record_test_app/app/views/models.rb +1 -0
- data/reactive_record_test_app/app/views/models/address.rb +13 -0
- data/reactive_record_test_app/app/views/models/comment.rb +19 -0
- data/reactive_record_test_app/app/views/models/todo_item.rb +36 -0
- data/reactive_record_test_app/app/views/models/user.rb +78 -0
- data/reactive_record_test_app/config.ru +33 -0
- data/reactive_record_test_app/config/application.rb +73 -0
- data/reactive_record_test_app/config/boot.rb +10 -0
- data/reactive_record_test_app/config/database.yml +25 -0
- data/reactive_record_test_app/config/environment.rb +5 -0
- data/reactive_record_test_app/config/environments/development.rb +43 -0
- data/reactive_record_test_app/config/environments/production.rb +70 -0
- data/reactive_record_test_app/config/environments/test.rb +41 -0
- data/reactive_record_test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/reactive_record_test_app/config/initializers/inflections.rb +15 -0
- data/reactive_record_test_app/config/initializers/mime_types.rb +5 -0
- data/reactive_record_test_app/config/initializers/secret_token.rb +7 -0
- data/reactive_record_test_app/config/initializers/session_store.rb +8 -0
- data/reactive_record_test_app/config/initializers/wrap_parameters.rb +14 -0
- data/reactive_record_test_app/config/locales/en.yml +5 -0
- data/reactive_record_test_app/config/routes.rb +7 -0
- data/reactive_record_test_app/db/migrate/20150617002932_create_todo_items.rb +11 -0
- data/reactive_record_test_app/db/migrate/20150617134028_create_users.rb +14 -0
- data/reactive_record_test_app/db/migrate/20150729195556_add_address_to_user.rb +20 -0
- data/reactive_record_test_app/db/migrate/20150826142045_create_comments.rb +10 -0
- data/reactive_record_test_app/db/migrate/20150828172008_add_single_comment_to_todo_item.rb +5 -0
- data/reactive_record_test_app/db/migrate/20150908184118_add_address_id_to_user.rb +5 -0
- data/reactive_record_test_app/db/migrate/20150917220236_add_second_address_to_user.rb +10 -0
- data/reactive_record_test_app/db/migrate/20151009000111_add_test_data_attributes_to_user.rb +6 -0
- data/reactive_record_test_app/db/migrate/20160129182544_add_test_enum_to_user.rb +5 -0
- data/reactive_record_test_app/db/schema.rb +63 -0
- data/reactive_record_test_app/db/seeds.rb +60 -0
- data/reactive_record_test_app/public/404.html +26 -0
- data/reactive_record_test_app/public/422.html +26 -0
- data/reactive_record_test_app/public/500.html +25 -0
- data/reactive_record_test_app/public/favicon.ico +0 -0
- data/reactive_record_test_app/script/rails +6 -0
- data/reactive_record_test_app/spec-opal/active-record/aggregations_spec.rb +41 -0
- data/reactive_record_test_app/spec-opal/active-record/associations_spec.rb +75 -0
- data/reactive_record_test_app/spec-opal/active-record/base_spec.rb +126 -0
- data/reactive_record_test_app/spec-opal/active-record/dummy_value_spec.rb +27 -0
- data/reactive_record_test_app/spec-opal/active-record/edge_cases_spec.rb +116 -0
- data/reactive_record_test_app/spec-opal/active-record/enum_spec.rb +43 -0
- data/reactive_record_test_app/spec-opal/active-record/instance_methods_spec.rb +53 -0
- data/reactive_record_test_app/spec-opal/active-record/non_ar_aggregations_spec.rb +74 -0
- data/reactive_record_test_app/spec-opal/active-record/permissions_spec.rb +170 -0
- data/reactive_record_test_app/spec-opal/active-record/prerendering_spec.rb +49 -0
- data/reactive_record_test_app/spec-opal/active-record/reactive_record_load_spec.rb +23 -0
- data/reactive_record_test_app/spec-opal/active-record/rendering_spec.rb +221 -0
- data/reactive_record_test_app/spec-opal/active-record/save_spec.rb +125 -0
- data/reactive_record_test_app/spec-opal/active-record/scope_spec.rb +85 -0
- data/reactive_record_test_app/spec-opal/active-record/update_aggregations_spec.rb +76 -0
- data/reactive_record_test_app/spec-opal/active-record/update_attributes_spec.rb +186 -0
- data/reactive_record_test_app/spec-opal/active-record/virtual_methods_spec.rb +71 -0
- data/reactive_record_test_app/spec-opal/index.html.erb +11 -0
- data/reactive_record_test_app/spec-opal/spec_helper.js.rb +268 -0
- data/reactive_record_test_app/spec-opal/vendor/es5-shim.min.js +6 -0
- data/reactive_record_test_app/spec_dont_run/README.md +26 -0
- data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzmany_to_many_spec_moved_to_main_suite.rb +30 -0
- data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzrevert_record_spec_moved.rb +78 -0
- data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzupdate_associations_spec_moved.rb +142 -0
- data/reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir/zzzupdate_scopes_movedspec.rb +48 -0
- data/remote.md +115 -0
- data/spec/bin/firebug-2.0.13-fx.xpi +0 -0
- data/spec/component_helpers_xspec.rb +49 -0
- data/spec/factories/child_model.rb +5 -0
- data/spec/factories/comment.rb +5 -0
- data/spec/factories/test_models.rb +5 -0
- data/spec/factories/todo.rb +5 -0
- data/spec/factories/user.rb +5 -0
- data/spec/reactive_record/edge_cases_spec.rb +31 -0
- data/spec/reactive_record/factory.rb +62 -0
- data/spec/reactive_record/many_to_many_spec.rb +50 -0
- data/spec/reactive_record/play.rb +64 -0
- data/spec/reactive_record/pry_rescue_xspec.rb +48 -0
- data/spec/reactive_record/revert_spec.rb +112 -0
- data/spec/reactive_record/update_associations_spec.rb +189 -0
- data/spec/reactive_record/update_scopes_spec.rb +53 -0
- data/spec/spec_helper.rb +366 -0
- data/spec/support/component_helpers.rb +351 -0
- data/spec/synchromesh/column_types/column_type_spec.rb +302 -0
- data/spec/synchromesh/connection_spec.rb +144 -0
- data/spec/synchromesh/crud_access_regulation/broadcast_controls_access_spec.rb +105 -0
- data/spec/synchromesh/crud_access_regulation/model_policies_spec.rb +131 -0
- data/spec/synchromesh/examples/dictionary.rb +239 -0
- data/spec/synchromesh/examples/dictionary_with_client_scopes.rb +196 -0
- data/spec/synchromesh/examples/random_examples.rb +100 -0
- data/spec/synchromesh/examples/scoped_todos_spec.rb +167 -0
- data/spec/synchromesh/integration/authorization_spec.rb +111 -0
- data/spec/synchromesh/integration/default_scope_spec.rb +121 -0
- data/spec/synchromesh/integration/has_many_through_spec.rb +173 -0
- data/spec/synchromesh/integration/relationships_spec.rb +263 -0
- data/spec/synchromesh/integration/scope_spec.rb +553 -0
- data/spec/synchromesh/integration/synchromesh_spec.rb +80 -0
- data/spec/synchromesh/integration/test_components.rb +18 -0
- data/spec/synchromesh/integration/transports_spec.rb +308 -0
- data/spec/synchromesh/policies/auto_connect_spec.rb +60 -0
- data/spec/synchromesh/policies/auto_loader_spec.rb +34 -0
- data/spec/synchromesh/policies/policy_methods_spec.rb +85 -0
- data/spec/synchromesh/policies/regulate_all_broadcasts_spec.rb +315 -0
- data/spec/synchromesh/policies/regulate_broadcast_spec.rb +370 -0
- data/spec/synchromesh/policies/regulate_class_connection_spec.rb +50 -0
- data/spec/synchromesh/policies/regulate_instance_connection_spec.rb +66 -0
- data/spec/test_app/Gemfile +61 -0
- data/spec/test_app/Gemfile.lock +253 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/javascripts/application.js +6 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/controllers/application_controller.rb +13 -0
- data/spec/test_app/app/controllers/test_controller.rb +5 -0
- data/spec/test_app/app/models/_react_public_models.rb +2 -0
- data/spec/test_app/app/models/public/address.rb +13 -0
- data/spec/test_app/app/models/public/child_model.rb +3 -0
- data/spec/test_app/app/models/public/comment.rb +25 -0
- data/spec/test_app/app/models/public/test_model.rb +5 -0
- data/spec/test_app/app/models/public/todo.rb +6 -0
- data/spec/test_app/app/models/public/todo_item.rb +36 -0
- data/spec/test_app/app/models/public/user.rb +88 -0
- data/spec/test_app/app/policies/auto_loader_test_classa_policy.rb +3 -0
- data/spec/test_app/app/policies/auto_loader_test_classb_policy.rb +3 -0
- data/spec/test_app/app/policies/auto_loader_test_classc_policy.rb +3 -0
- data/spec/test_app/app/policies/auto_loader_test_classd_policy.rb +3 -0
- data/spec/test_app/app/views/components.rb +14 -0
- data/spec/test_app/app/views/components/show.rb +5 -0
- data/spec/test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/bin/setup +29 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/config/application.rb +42 -0
- data/spec/test_app/config/boot.rb +6 -0
- data/spec/test_app/config/cable.yml +10 -0
- data/spec/test_app/config/database.yml +47 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +41 -0
- data/spec/test_app/config/environments/production.rb +79 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/assets.rb +11 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/session_store.rb +3 -0
- data/spec/test_app/config/initializers/synchromesh.rb +11 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/routes.rb +61 -0
- data/spec/test_app/config/secrets.yml +22 -0
- data/spec/test_app/db/development.sqlite3 +0 -0
- data/spec/test_app/db/migrate/20160731182106_create_test_models.rb +75 -0
- data/spec/test_app/db/schema.rb +88 -0
- data/spec/test_app/db/seeds.rb +7 -0
- data/spec/test_app/lib/assets/.keep +0 -0
- data/spec/test_app/log/.keep +0 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/vendor/es5-shim.min.js +6 -0
- data/terminal.md +66 -0
- metadata +1175 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
#require 'rails'
|
2
|
+
|
3
|
+
module ReactiveRecord
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace ReactiveRecord
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec, :fixture => false
|
8
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
9
|
+
g.assets false
|
10
|
+
g.helper false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Browser
|
2
|
+
|
3
|
+
# Allows you to create an interval that executes the function every given
|
4
|
+
# seconds.
|
5
|
+
#
|
6
|
+
# @see https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval
|
7
|
+
class Interval
|
8
|
+
# @!attribute [r] every
|
9
|
+
# @return [Float] the seconds every which the block is called
|
10
|
+
attr_reader :every
|
11
|
+
|
12
|
+
# Create and start an interval.
|
13
|
+
#
|
14
|
+
# @param window [Window] the window to start the interval on
|
15
|
+
# @param time [Float] seconds every which to call the block
|
16
|
+
def initialize(window, time, &block)
|
17
|
+
@window = Native.convert(window)
|
18
|
+
@every = time
|
19
|
+
@block = block
|
20
|
+
|
21
|
+
@aborted = false
|
22
|
+
end
|
23
|
+
|
24
|
+
# Check if the interval has been stopped.
|
25
|
+
def stopped?
|
26
|
+
@id.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
# Check if the interval has been aborted.
|
30
|
+
def aborted?
|
31
|
+
@aborted
|
32
|
+
end
|
33
|
+
|
34
|
+
# Abort the interval, it won't be possible to start it again.
|
35
|
+
def abort
|
36
|
+
`#@window.clearInterval(#@id)`
|
37
|
+
|
38
|
+
@aborted = true
|
39
|
+
@id = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
# Stop the interval, it will be possible to start it again.
|
43
|
+
def stop
|
44
|
+
return if stopped?
|
45
|
+
|
46
|
+
`#@window.clearInterval(#@id)`
|
47
|
+
|
48
|
+
@stopped = true
|
49
|
+
@id = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
# Start the interval if it has been stopped.
|
53
|
+
def start
|
54
|
+
raise "the interval has been aborted" if aborted?
|
55
|
+
return unless stopped?
|
56
|
+
|
57
|
+
@id = `#@window.setInterval(#@block, #@every * 1000)`
|
58
|
+
end
|
59
|
+
|
60
|
+
# Call the [Interval] block.
|
61
|
+
def call
|
62
|
+
@block.call
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Window
|
67
|
+
# Execute the block every given seconds.
|
68
|
+
#
|
69
|
+
# @param time [Float] the seconds between every call
|
70
|
+
#
|
71
|
+
# @return [Interval] the object representing the interval
|
72
|
+
def every(time, &block)
|
73
|
+
Interval.new(@native, time, &block).tap(&:start)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Execute the block every given seconds, you have to call [#start] on it
|
77
|
+
# yourself.
|
78
|
+
#
|
79
|
+
# @param time [Float] the seconds between every call
|
80
|
+
#
|
81
|
+
# @return [Interval] the object representing the interval
|
82
|
+
def every!(time, &block)
|
83
|
+
Interval.new(@native, time, &block)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
module Kernel
|
90
|
+
# (see Browser::Window#every)
|
91
|
+
def every(time, &block)
|
92
|
+
$window.every(time, &block)
|
93
|
+
end
|
94
|
+
|
95
|
+
# (see Browser::Window#every!)
|
96
|
+
def every!(time, &block)
|
97
|
+
$window.every!(time, &block)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class Proc
|
102
|
+
# (see Browser::Window#every)
|
103
|
+
def every(time)
|
104
|
+
$window.every(time, &self)
|
105
|
+
end
|
106
|
+
|
107
|
+
# (see Browser::Window#every!)
|
108
|
+
def every!(time)
|
109
|
+
$window.every!(time, &self)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
module Browser
|
114
|
+
|
115
|
+
# Allows you to delay the call to a function which gets called after the
|
116
|
+
# given time.
|
117
|
+
#
|
118
|
+
# @see https://developer.mozilla.org/en-US/docs/Web/API/Window.setTimeout
|
119
|
+
class Delay
|
120
|
+
# @!attribute [r] after
|
121
|
+
# @return [Float] the seconds after which the block is called
|
122
|
+
attr_reader :after
|
123
|
+
|
124
|
+
# Create and start a timeout.
|
125
|
+
#
|
126
|
+
# @param window [Window] the window to start the timeout on
|
127
|
+
# @param time [Float] seconds after which the block is called
|
128
|
+
def initialize(window, time, &block)
|
129
|
+
@window = Native.convert(window)
|
130
|
+
@after = time
|
131
|
+
@block = block
|
132
|
+
end
|
133
|
+
|
134
|
+
# Abort the timeout.
|
135
|
+
def abort
|
136
|
+
`#@window.clearTimeout(#@id)`
|
137
|
+
end
|
138
|
+
|
139
|
+
# Start the delay.
|
140
|
+
def start
|
141
|
+
@id = `#@window.setTimeout(#{@block.to_n}, #@after * 1000)`
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class Window
|
146
|
+
# Execute a block after the given seconds.
|
147
|
+
#
|
148
|
+
# @param time [Float] the seconds after it gets called
|
149
|
+
#
|
150
|
+
# @return [Delay] the object representing the timeout
|
151
|
+
def after(time, &block)
|
152
|
+
Delay.new(@native, time, &block).tap(&:start)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Execute a block after the given seconds, you have to call [#start] on it
|
156
|
+
# yourself.
|
157
|
+
#
|
158
|
+
# @param time [Float] the seconds after it gets called
|
159
|
+
#
|
160
|
+
# @return [Delay] the object representing the timeout
|
161
|
+
def after!(time, &block)
|
162
|
+
Delay.new(@native, time, &block)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
module Kernel
|
169
|
+
# (see Browser::Window#after)
|
170
|
+
def after(time, &block)
|
171
|
+
`setTimeout(#{block.to_n}, time * 1000)`
|
172
|
+
end
|
173
|
+
|
174
|
+
# (see Browser::Window#after!)
|
175
|
+
def after!(time, &block)
|
176
|
+
`setTimeout(#{block.to_n}, time * 1000)`
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class Proc
|
181
|
+
# (see Browser::Window#after)
|
182
|
+
def after(time)
|
183
|
+
$window.after(time, &self)
|
184
|
+
end
|
185
|
+
|
186
|
+
# (see Browser::Window#after!)
|
187
|
+
def after!(time)
|
188
|
+
$window.after!(time, &self)
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module ReactiveRecord
|
2
|
+
class AccessViolation < StandardError
|
3
|
+
def message
|
4
|
+
"ReactiveRecord::AccessViolation: #{super}"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class ActiveRecord::Base
|
10
|
+
|
11
|
+
attr_accessor :acting_user
|
12
|
+
|
13
|
+
def create_permitted?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_permitted?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy_permitted?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def view_permitted?(attribute)
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def only_changed?(*attributes)
|
30
|
+
(self.attributes.keys + self.class.reactive_record_association_keys).each do |key|
|
31
|
+
return false if self.send("#{key}_changed?") and !attributes.include? key
|
32
|
+
end
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def none_changed?(*attributes)
|
37
|
+
attributes.each do |key|
|
38
|
+
return false if self.send("#{key}_changed?")
|
39
|
+
end
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
def any_changed?(*attributes)
|
44
|
+
attributes.each do |key|
|
45
|
+
return true if self.send("#{key}_changed?")
|
46
|
+
end
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
def all_changed?(*attributes)
|
51
|
+
attributes.each do |key|
|
52
|
+
return false unless self.send("#{key}_changed?")
|
53
|
+
end
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
class << self
|
58
|
+
|
59
|
+
attr_reader :reactive_record_association_keys
|
60
|
+
|
61
|
+
[:has_many, :belongs_to, :composed_of].each do |macro|
|
62
|
+
define_method "#{macro}_with_reactive_record_add_changed_method".to_sym do |attr_name, *args, &block|
|
63
|
+
define_method "#{attr_name}_changed?".to_sym do
|
64
|
+
instance_variable_get "@reactive_record_#{attr_name}_changed".to_sym
|
65
|
+
end
|
66
|
+
(@reactive_record_association_keys ||= []) << attr_name
|
67
|
+
send "#{macro}_without_reactive_record_add_changed_method".to_sym, attr_name, *args, &block
|
68
|
+
end
|
69
|
+
alias_method "#{macro}_without_reactive_record_add_changed_method".to_sym, macro
|
70
|
+
alias_method macro, "#{macro}_with_reactive_record_add_changed_method".to_sym
|
71
|
+
end
|
72
|
+
|
73
|
+
alias belongs_to_without_reactive_record_add_is_method belongs_to
|
74
|
+
|
75
|
+
def belongs_to(attr_name, scope = nil, options = {})
|
76
|
+
define_method "#{attr_name}_is?".to_sym do |model|
|
77
|
+
send(options[:foreign_key] || "#{attr_name}_id") == model.id
|
78
|
+
end
|
79
|
+
belongs_to_without_reactive_record_add_is_method(attr_name, scope, options)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def check_permission_with_acting_user(user, permission, *args)
|
85
|
+
old = acting_user
|
86
|
+
self.acting_user = user
|
87
|
+
if self.send(permission, *args)
|
88
|
+
self.acting_user = old
|
89
|
+
self
|
90
|
+
else
|
91
|
+
raise ReactiveRecord::AccessViolation, "for #{permission}(#{args})"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
class ActionController::Base
|
98
|
+
|
99
|
+
def acting_user
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# class ActiveRecord::Base
|
2
|
+
#
|
3
|
+
# def self.to_sync(scope_name, opts={}, &block)
|
4
|
+
# watch_list = if opts[:watch]
|
5
|
+
# [*opts.delete[:watch]]
|
6
|
+
# else
|
7
|
+
# [self]
|
8
|
+
# end
|
9
|
+
# if RUBY_ENGINE=='opal'
|
10
|
+
# watch_list.each do |klass_to_watch|
|
11
|
+
# ReactiveRecord::Base.sync_blocks[klass_to_watch][self][scope_name] << block
|
12
|
+
# end
|
13
|
+
# else
|
14
|
+
# # this is where we put server side watchers in place to sync all clients!
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module ReactiveRecord
|
2
|
+
# Keeps track of the details (client side) of a scope.
|
3
|
+
# The main point is to provide knowledge of what models
|
4
|
+
# the scope is joined with, and the client side
|
5
|
+
# filter proc
|
6
|
+
class ScopeDescription
|
7
|
+
def initialize(model, name, opts)
|
8
|
+
sself = self
|
9
|
+
model.singleton_class.send(:define_method, "_#{name}_synchromesh_scope_description_") do
|
10
|
+
sself
|
11
|
+
end
|
12
|
+
@filter_proc = filter_proc(opts)
|
13
|
+
@name = name
|
14
|
+
@model = model
|
15
|
+
build_joins opts[:joins]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find(target_model, name)
|
19
|
+
target_model.send "_#{name}_synchromesh_scope_description_"
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter?
|
23
|
+
@filter_proc.respond_to?(:call)
|
24
|
+
end
|
25
|
+
|
26
|
+
def collector?
|
27
|
+
@is_collector
|
28
|
+
end
|
29
|
+
|
30
|
+
def joins_with?(record)
|
31
|
+
@joins.detect do |klass, vector|
|
32
|
+
vector.any? && (klass == :all || record.class == klass || record.class < klass)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def related_records_for(record)
|
37
|
+
ReactiveRecord::Base.catch_db_requests([]) do
|
38
|
+
(@joins[record.class.base_class] || @joins[:all]).collect do |vector|
|
39
|
+
crawl(record, *vector)
|
40
|
+
end.flatten.compact
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter_records(related_records, args)
|
45
|
+
if collector?
|
46
|
+
Set.new(related_records.to_a.instance_exec(*args, &@filter_proc))
|
47
|
+
else
|
48
|
+
Set.new(related_records.select { |r| r.instance_exec(*args, &@filter_proc) })
|
49
|
+
end
|
50
|
+
rescue Exception => e
|
51
|
+
raise "Client side scope #{@model}.#{@name} raised error: #{e.message}"
|
52
|
+
end
|
53
|
+
|
54
|
+
# private methods
|
55
|
+
|
56
|
+
def filter_proc(opts)
|
57
|
+
return true unless opts.key?(:client) || opts.key?(:select)
|
58
|
+
client_opt = opts[:client] || opts[:select]
|
59
|
+
@is_collector = opts.key?(:select)
|
60
|
+
return client_opt if !client_opt || client_opt.respond_to?(:call)
|
61
|
+
raise 'Scope option :client or :select must be a proc, false, or nil'
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_joins(joins_list)
|
65
|
+
if !@filter_proc || joins_list == []
|
66
|
+
@joins = { all: [] }
|
67
|
+
elsif joins_list.nil?
|
68
|
+
@joins = { @model => [[]], all: [] }
|
69
|
+
elsif joins_list == :all
|
70
|
+
@joins = { all: [[]] }
|
71
|
+
else
|
72
|
+
joins_list = [joins_list] unless joins_list.is_a? Array
|
73
|
+
map_joins_path joins_list
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def map_joins_path(paths)
|
78
|
+
@joins = Hash.new { |h, k| h[k] = Array.new }.merge(@model => [[]])
|
79
|
+
paths.each do |path|
|
80
|
+
vector = []
|
81
|
+
path.split('.').inject(@model) do |model, attribute|
|
82
|
+
association = model.reflect_on_association(attribute)
|
83
|
+
raise build_error(path, model, attribute) unless association
|
84
|
+
vector = [association.inverse_of, *vector]
|
85
|
+
@joins[association.klass] << vector
|
86
|
+
association.klass
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_error(path, model, attribute)
|
92
|
+
"Could not find joins association '#{model.name}.#{attribute}' "\
|
93
|
+
"for '#{path}' while processing scope #{@model.name}.#{@name}."
|
94
|
+
end
|
95
|
+
|
96
|
+
def crawl(item, method = nil, *vector)
|
97
|
+
if !method && item.is_a?(Collection)
|
98
|
+
item.all
|
99
|
+
elsif !method
|
100
|
+
item
|
101
|
+
elsif item.respond_to? :collect
|
102
|
+
item.collect { |record| crawl(record.send(method), *vector) }
|
103
|
+
else
|
104
|
+
crawl(item.send(method), *vector)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|