slender_data 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/slender_data.coffee +14 -0
- data/app/assets/javascripts/slender_data/brest_loader.coffee +139 -0
- data/app/assets/javascripts/slender_data/cache.coffee +9 -24
- data/app/assets/javascripts/slender_data/entry_store.coffee +107 -0
- data/app/assets/javascripts/slender_data/loading_indicator.coffee +28 -0
- data/app/assets/javascripts/slender_data/loading_tracker.coffee +74 -0
- data/app/assets/javascripts/slender_data/parameterizable.coffee +50 -0
- data/app/assets/javascripts/slender_data/persistence_manager.coffee +114 -233
- data/app/assets/javascripts/slender_data/queries/base_query.coffee +32 -0
- data/app/assets/javascripts/slender_data/queries/multi_query.coffee +91 -0
- data/app/assets/javascripts/slender_data/queries/single_query.coffee +81 -0
- data/app/assets/javascripts/slender_data/query_cache.coffee +87 -0
- data/lib/slender_data/version.rb +1 -1
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +31 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/tasks/tasks.rake +13 -0
- data/spec/dummy/log/development.log +349013 -0
- data/spec/dummy/log/test.log +883 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/javascripts/brest_loader_spec.coffee +314 -0
- data/spec/dummy/spec/javascripts/cache_spec.coffee +93 -0
- data/spec/dummy/spec/javascripts/entry_store_spec.coffee +315 -0
- data/spec/dummy/spec/javascripts/jquery.js +6 -0
- data/spec/dummy/spec/javascripts/loading_tracker_spec.coffee +95 -0
- data/spec/dummy/spec/javascripts/parameterizable_spec.coffee +138 -0
- data/spec/dummy/spec/javascripts/persistence_manager_spec.coffee +659 -0
- data/spec/dummy/spec/javascripts/queries/base_query_spec.coffee +41 -0
- data/spec/dummy/spec/javascripts/queries/multi_query_spec.coffee +143 -0
- data/spec/dummy/spec/javascripts/queries/single_query_spec.coffee +112 -0
- data/spec/dummy/spec/javascripts/query_cache_spec.coffee +347 -0
- data/spec/dummy/spec/javascripts/sinon-chai.js +109 -0
- data/spec/dummy/spec/javascripts/sinon.js +4290 -0
- data/spec/dummy/spec/javascripts/spec_helper.coffee +23 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/02dabf70b4ae4a034f349ce89b4831d8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/031a6c2e3a4e952151301446bd3fc16d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0373c4e5507b3195c4ad15224d991609 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/05175bd457a57c3ad73ab9a2c8696c9b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/086e89c7529d5063e771b41793bfe311 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/08b36042c3a4a79ebd9cee8ee1b88e6a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/10513fd445754b59bd6001ea6ee727d9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/124f6816f926ae28ad20cc56425f3c91 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/12ce2414098e368903aeb9923e275ef7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/14eca89f8dccac139fd132de35d22628 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/16c8b12ef6dcb486a7b771e43bbcc117 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/19cdfaa89f900500a03507b86afe1231 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1b3a4d533a743ca2ccfbca0986613995 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1ca8c5b832302c6c94692d0875a59605 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2e2576241d2a4969c9277fe85851c92b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2ec1baba6d6dc634d091b3acf8127cf7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2ff315acad8ceec317fd566d792df64f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/311f68c1b9e342ebab4c92c8cb2b5e54 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/324a5040c964d5e8d293564383c49b91 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3310b5a70d0b220782ab3e87642834e9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/33ea745e7aa9669831758b7d36db1cb4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3999afdceee7ca8dcf53757221c62d71 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3ba03b9f1aab60e78424f36e0e6cce6c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3e9a6ed890157d94f18b480f0079d8e1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3ef50ccfe459d5c89ecc79a448586b49 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/46c298dc2ff12ec748c70c017684fc28 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/476318dd8109fbf173335456cabb4128 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5602ee157ea76a2f44a43739a83b1a6c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5b390f4782d6b77f5aec7ec56f3ad934 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5b5a66f4eefc591d284af6535ae474ea +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5c41eeb2e98dc0833647e8547880435e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5cd2936d626662390288ab4c07ff3957 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5fd362891a204d492d9fa57ffee6e114 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/643d60abdbcc813c95214920f12f09c3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6591bc7545da5a2f5f7dee20b1f110a5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6597f36181468ff92ba4284afe001181 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/69b7946c418b75e7ba78f9fc73d3e9b9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6c75b81de9afea82a6cbb56749157e3f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6e4bc63f9308eb5929a77f7607101af1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6ee2243cf1cf415b6267b84dd7b8ba77 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6f8457b4ba418f572891745381a1e0f5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fd5544e52538b06ac40e5b387b020a5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fed8361766f5ae3cbf781986d6945b2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/70ffa648dbbe0f2431e7f9307b569354 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/731f0bc492f775825f046d500938fc5a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/76153dd2cc3d0c6e584080efb16e872a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/76cd4393e7976d030f4623b8b6b372a0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/78d5dac5e2f907dd68813ed23a0fd4ac +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7a400f93bfb71a1a11c59b9804adda6d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7abf5e8d9666225cb1d7881798dbd87a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7d6f1f3e48f6cc97a9bb4606f8c5a020 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/814ca144649e7dec9e9158b3ec3460f1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/83de5b2d2c5d49f7737ae1f0316435ec +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/84c67faa73fdd082d4bd7f7712cb0499 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87a6ddc523ccbf2673750499bede3fc9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8a90082fa76a7f37dd92a9b9a9b9f593 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8c5b622a33c6c034ecb4e78f131c5f73 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8c9851849e82bb9670e56f046df437f9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8fc1455d3af69de5da04bf2a2a3f0b74 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/96af98519e5badf206b77c3ecaf86d20 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/98610661915880264fdb51c8f1a14141 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9a00753cdfb01f357dc39eeada77d0bc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9ad3db355e00d28ed3faed6dea5b1bff +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9cbb3109d489692fd270c77ffa9d9559 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a22afac508f5adc12bf48d2f8333b8f7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a49d020ee42c78bf7d22a21e8ee3b80f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a4f4f6c56c368263c0fbcf3f1542aa73 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a56b8266298c4171918ee403aa1c9e0f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a73a44bfca198fdf779532b644ec8af5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/aa4a22da44bd1b7dbdbb18f983d6c09b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ab0236bf3eac5cd30348c18efce8246b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/abf215c8dc45135a91f4f993514c653f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ac1b8c30ad00cc489b7ec78bd6e2fc6c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ae8bd07980ad64ef8e9ac3fe38413c6d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b1950420978c68074fc6fd81d4320bc0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b2d6aa1cb303474ebf3bfc571904ad23 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b59a10f85562b39fc7dd651965df9cab +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b8d24bca037cf4b0a9e2979c11c8aea8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bc2f15f88df08b4265c83133d6107680 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bd7ddfa86995ff5d259ea37e4a90c51c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c0515d57887926d6e28a0f87da31ee8e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c4820232e07d4e298e834c1011a72faa +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c6babc078901541de3f4cb5cc2703bea +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c9635dd5cbd79bdd9c58a89f6ea01595 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c9962abce37f5a56d5f05afe1edfe1b8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cce1f28f0d1f5c2817e6eaf392bac615 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d37cae0bfdf135e6e71bcd0572bef329 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d4956056f6f35287a04295df6e52575d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dc54acb6b8cd4b84b13f440d57db37b1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dd51c50b2d8231175e8da83e8b057120 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dec2df59b57b3639f89847e50416c924 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/df45b0abc2c323093874639ceb72c012 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e0393ec0ca968f0d4182c82802da79d5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e43bfee690613c316a59f122315314e5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ed1d892145be7053348b0ba28c27b427 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ef2b922f05692ba49eb1f68801786b8e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/efec5fde178e0875317a0d380222545d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f01906d52258e56e92a230dc3e55805d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f1b4ffa23205a95782c5c5050359429f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f2080a87aa027245a444b1486dce7792 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f37842723e3572ba18f02519dab4ee77 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f72501aca20f34d765720253853e6105 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f74306735334107c5d17684f524b65cf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f89dc49f90e98b448540556861f0173e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/feadb1611975b23f2647e1ac656ad90b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ff445b9646db9910af486791b285b112 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ffa1eaa25729d9d4cd7e2fd666868936 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/02dabf70b4ae4a034f349ce89b4831d8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/031a6c2e3a4e952151301446bd3fc16d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0373c4e5507b3195c4ad15224d991609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/05175bd457a57c3ad73ab9a2c8696c9b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/086e89c7529d5063e771b41793bfe311 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/08b36042c3a4a79ebd9cee8ee1b88e6a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/10513fd445754b59bd6001ea6ee727d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/124f6816f926ae28ad20cc56425f3c91 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/14eca89f8dccac139fd132de35d22628 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/16c8b12ef6dcb486a7b771e43bbcc117 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2b22662f42e9f485aafa6a333faaa256 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2e2576241d2a4969c9277fe85851c92b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2ec1baba6d6dc634d091b3acf8127cf7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2ff315acad8ceec317fd566d792df64f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/311f68c1b9e342ebab4c92c8cb2b5e54 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/324a5040c964d5e8d293564383c49b91 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3310b5a70d0b220782ab3e87642834e9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/33ea745e7aa9669831758b7d36db1cb4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3999afdceee7ca8dcf53757221c62d71 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3e9a6ed890157d94f18b480f0079d8e1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3ef50ccfe459d5c89ecc79a448586b49 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/46c298dc2ff12ec748c70c017684fc28 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/476318dd8109fbf173335456cabb4128 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5602ee157ea76a2f44a43739a83b1a6c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5b390f4782d6b77f5aec7ec56f3ad934 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5b5a66f4eefc591d284af6535ae474ea +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5cd2936d626662390288ab4c07ff3957 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/643d60abdbcc813c95214920f12f09c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6597f36181468ff92ba4284afe001181 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6c75b81de9afea82a6cbb56749157e3f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6e4bc63f9308eb5929a77f7607101af1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6ee2243cf1cf415b6267b84dd7b8ba77 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6f8457b4ba418f572891745381a1e0f5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fd5544e52538b06ac40e5b387b020a5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fed8361766f5ae3cbf781986d6945b2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/70ffa648dbbe0f2431e7f9307b569354 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/76cd4393e7976d030f4623b8b6b372a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7a400f93bfb71a1a11c59b9804adda6d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7abf5e8d9666225cb1d7881798dbd87a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7d6f1f3e48f6cc97a9bb4606f8c5a020 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/814ca144649e7dec9e9158b3ec3460f1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/83de5b2d2c5d49f7737ae1f0316435ec +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/873c5252aa4eab7409b712c5e276bad2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87a6ddc523ccbf2673750499bede3fc9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8a90082fa76a7f37dd92a9b9a9b9f593 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8c5b622a33c6c034ecb4e78f131c5f73 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8c9851849e82bb9670e56f046df437f9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8fc1455d3af69de5da04bf2a2a3f0b74 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/98610661915880264fdb51c8f1a14141 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9a00753cdfb01f357dc39eeada77d0bc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ad3db355e00d28ed3faed6dea5b1bff +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a22afac508f5adc12bf48d2f8333b8f7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a4f4f6c56c368263c0fbcf3f1542aa73 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a56b8266298c4171918ee403aa1c9e0f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a73a44bfca198fdf779532b644ec8af5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa4a22da44bd1b7dbdbb18f983d6c09b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ab0236bf3eac5cd30348c18efce8246b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ac1b8c30ad00cc489b7ec78bd6e2fc6c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ae8bd07980ad64ef8e9ac3fe38413c6d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b1950420978c68074fc6fd81d4320bc0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b2d6aa1cb303474ebf3bfc571904ad23 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b8d24bca037cf4b0a9e2979c11c8aea8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bc2f15f88df08b4265c83133d6107680 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c9962abce37f5a56d5f05afe1edfe1b8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cce1f28f0d1f5c2817e6eaf392bac615 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d37cae0bfdf135e6e71bcd0572bef329 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d4956056f6f35287a04295df6e52575d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dc54acb6b8cd4b84b13f440d57db37b1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd51c50b2d8231175e8da83e8b057120 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/df13b2e8a88a9dcdc4a830fdd8f8d7b8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/df45b0abc2c323093874639ceb72c012 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e0393ec0ca968f0d4182c82802da79d5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e43bfee690613c316a59f122315314e5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ed1d892145be7053348b0ba28c27b427 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ef2b922f05692ba49eb1f68801786b8e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f01906d52258e56e92a230dc3e55805d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f1b4ffa23205a95782c5c5050359429f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f2080a87aa027245a444b1486dce7792 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f37842723e3572ba18f02519dab4ee77 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f72501aca20f34d765720253853e6105 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/feadb1611975b23f2647e1ac656ad90b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ff445b9646db9910af486791b285b112 +0 -0
- metadata +499 -6
- data/app/assets/javascripts/slender_data.js +0 -8
- data/app/assets/javascripts/slender_data/ajax_loader.coffee +0 -76
- data/app/assets/javascripts/slender_data/indexed_cache.coffee +0 -33
@@ -1,271 +1,152 @@
|
|
1
|
-
#= require slender_data/
|
2
|
-
#= require slender_data/
|
1
|
+
#= require slender_data/brest_loader
|
2
|
+
#= require slender_data/entry_store
|
3
|
+
#= require slender_data/query_cache
|
4
|
+
#= require slender_data/parameterizable
|
3
5
|
#= require slender_data/tools
|
4
6
|
|
5
|
-
# Provides persistence services for data models.
|
7
|
+
# Provides server-backed persistence services for JSON data models.
|
6
8
|
#
|
7
|
-
# This class operates against a
|
8
|
-
# In addition to the standard RESTful routes, the data API is expected to support these methods for performance reasons:
|
9
|
-
# * DELETE /entries: Delete a whole batch of entries at once. The ids of the entries to delete are given as a JSON hash in the body of the request.
|
10
|
-
# *
|
9
|
+
# This class operates against a BRESTful data API.
|
11
10
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
class slender_data.PersistenceManager
|
11
|
+
# Operations that act directly on entries, and are always given entries
|
12
|
+
# (add_to_cache, create, update) are given the entries directly.
|
13
|
+
# Operations that need to look up entries before doing something with them,
|
14
|
+
# and don't necessarily need the full entry to do that, (delete, get, load)
|
15
|
+
# are given queries.
|
16
|
+
class slender_data.PersistenceManager extends slender_data.Parameterizable
|
19
17
|
|
20
18
|
constructor: (params) ->
|
19
|
+
super params
|
21
20
|
|
22
|
-
#
|
23
|
-
|
21
|
+
# Stores the data objects here on the client,
|
22
|
+
# and tracks changes that are made to them here.
|
23
|
+
@entry_store = new slender_data.EntryStore params
|
24
24
|
|
25
|
-
#
|
26
|
-
@
|
25
|
+
# Loads/stores data to/from the server.
|
26
|
+
@server_api = new slender_data.BrestLoader params
|
27
27
|
|
28
|
-
# The base url on the server. Expected to be a fully RESTful API.
|
29
|
-
@base_url = params.url
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
# Adds the given serverside entry to the entry store.
|
30
|
+
# Does not update the server.
|
31
|
+
# Does not provide an editable version of the data.
|
32
|
+
# Call "get" to get one.
|
33
|
+
add_to_cache: (entry) ->
|
34
|
+
@entry_store.add entry
|
33
35
|
|
34
|
-
# Name of the model class (e.g. "user").
|
35
|
-
@model_name = params.model_name
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
# Adds the given serverside entries to the entry store.
|
38
|
+
add_many_to_cache: (entries) ->
|
39
|
+
@entry_store.add_many entries
|
39
40
|
|
40
41
|
|
41
|
-
#
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
changed_objects_columns: (objects) ->
|
58
|
-
slender_data.tap [], (result) =>
|
59
|
-
for object in objects
|
60
|
-
diff = slender_data.object_diff @server_data.get(object[@key]), object
|
61
|
-
continue if slender_data.object_length(diff) == 0
|
62
|
-
diff[@key] = object[@key]
|
63
|
-
result.push(diff)
|
64
|
-
|
65
|
-
|
66
|
-
# Returns the URL to access the collection of objects.
|
67
|
-
collection_url: ->
|
68
|
-
"#{@base_url}.json"
|
69
|
-
|
70
|
-
|
71
|
-
# Creates the given object on the server.
|
72
|
-
create: (obj, success_callback, error_callback) ->
|
73
|
-
data = {}
|
74
|
-
data[@model_name] = obj
|
75
|
-
|
76
|
-
jQuery.ajax
|
77
|
-
url: @collection_url()
|
78
|
-
type: 'POST'
|
79
|
-
data: data
|
80
|
-
success: (server_response) =>
|
81
|
-
server_obj = server_response[@model_name]
|
82
|
-
@server_data.add server_obj
|
83
|
-
success_callback server_obj
|
84
|
-
error: (xhr) =>
|
85
|
-
error_callback(xhr.responseText) if error_callback
|
86
|
-
|
87
|
-
|
88
|
-
# TODO: create_many
|
89
|
-
|
90
|
-
|
91
|
-
# Deletes the given object from the server.
|
92
|
-
delete: (obj, success_callback, error_callback) ->
|
93
|
-
@client_data.remove obj
|
94
|
-
@server_data.remove obj
|
95
|
-
jQuery.ajax
|
96
|
-
url: @entry_url(obj)
|
97
|
-
type: 'DELETE'
|
98
|
-
success: ->
|
99
|
-
success_callback() if success_callback?
|
100
|
-
error: (xhr) ->
|
101
|
-
error_callback(xhr.responseText) if error_callback
|
102
|
-
|
103
|
-
|
104
|
-
# Deletes the given objects from the server.
|
105
|
-
delete_many: (object_ids, success_callback, error_callback) ->
|
106
|
-
@client_data.remove_many object_ids
|
107
|
-
@server_data.remove_many object_ids
|
108
|
-
jQuery.ajax
|
109
|
-
url: @base_url
|
110
|
-
type: 'DELETE'
|
111
|
-
data: {ids: object_ids}
|
112
|
-
success: ->
|
113
|
-
success_callback() if success_callback?
|
114
|
-
error: (xhr) ->
|
115
|
-
error_callback(xhr.responseText) if error_callback
|
116
|
-
|
117
|
-
|
118
|
-
# Returns the url to access a single entry.
|
119
|
-
entry_url: (entry) ->
|
120
|
-
"#{@base_url}/#{entry[@key]}.json"
|
121
|
-
|
122
|
-
|
123
|
-
# Returns the url to access the collection of entries.
|
124
|
-
entries_url: ->
|
125
|
-
"#{@base_url}.json"
|
126
|
-
|
127
|
-
|
128
|
-
# Fetches the entry with the given key from the server.
|
129
|
-
# Adds it to the clientside cache.
|
130
|
-
fetch: (key, success_callback) ->
|
131
|
-
@loader.get "#{@base_url}/#{key}.json", (server_response) =>
|
132
|
-
client_entry = @add server_response[@model_name]
|
133
|
-
success_callback client_entry
|
134
|
-
|
135
|
-
|
136
|
-
# Loads all objects from the server.
|
137
|
-
# Provides the given params as parameters to the GET request.
|
138
|
-
fetch_many: (data, success_callback, error_callback) ->
|
139
|
-
data.ids = data.ids.join(' ') if data.ids
|
140
|
-
jQuery.ajax
|
141
|
-
url: @collection_url()
|
142
|
-
cache: no
|
143
|
-
data: data
|
144
|
-
success: (data) =>
|
145
|
-
@add_all data
|
146
|
-
success_callback(data) if success_callback
|
147
|
-
error: (xhr) ->
|
148
|
-
error_callback(xhr.responseText) if error_callback
|
149
|
-
|
42
|
+
# Creates the described object on the server.
|
43
|
+
#
|
44
|
+
# Returns nothing. Call "get" to get an editable copy of the object.
|
45
|
+
create: (entry, callback) ->
|
46
|
+
@server_api.create entry, (server_response) =>
|
47
|
+
server_entry = server_response[@entry_name]
|
48
|
+
@add_to_cache server_entry
|
49
|
+
callback(@get entry: server_entry) if callback
|
50
|
+
|
51
|
+
# Creates the described objects on the server.
|
52
|
+
#
|
53
|
+
# Returns nothing. Call "get_many" to get editable copies.
|
54
|
+
create_many: (entries, callback) ->
|
55
|
+
@server_api.create_many entries, (server_response) =>
|
56
|
+
@add_many_to_cache server_response[@entries_name]
|
57
|
+
callback() if callback
|
150
58
|
|
151
|
-
# Returns the cached object with the given key, if one exists in the cache.
|
152
|
-
# Returns undefined if no object with this key exists in the cache.
|
153
|
-
get: (key) =>
|
154
59
|
|
155
|
-
|
156
|
-
|
157
|
-
|
60
|
+
# Deletes the described entry from the server.
|
61
|
+
delete: (query, callback) ->
|
62
|
+
query = query
|
63
|
+
@server_api.delete query, (server_response) =>
|
64
|
+
@entry_store.delete server_response
|
65
|
+
callback(server_response) if callback
|
158
66
|
|
159
|
-
# No data in client cache --> try to use server cache.
|
160
|
-
server_obj = @server_data.get key
|
161
|
-
if server_obj
|
162
|
-
client_obj = slender_data.clone_hash server_obj
|
163
|
-
@client_data.add client_obj
|
164
|
-
return client_obj
|
165
67
|
|
166
|
-
|
167
|
-
|
68
|
+
# Deletes the described entries from the server.
|
69
|
+
delete_many: (multi_query, callback) ->
|
70
|
+
@server_api.delete_many multi_query, (server_response) =>
|
71
|
+
@entry_store.delete_many server_response
|
72
|
+
callback(server_response) if callback
|
168
73
|
|
169
74
|
|
170
|
-
#
|
171
|
-
#
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
for id in ids
|
176
|
-
if (entry = @get id)
|
177
|
-
entries.push entry
|
178
|
-
else
|
179
|
-
missing_ids.push id
|
180
|
-
[entries, missing_ids]
|
75
|
+
# Synchronously returns the described entry from the cache,
|
76
|
+
# or undefined if there is no cached entry.
|
77
|
+
# Does not query the server.
|
78
|
+
get: (query) =>
|
79
|
+
@entry_store.get query
|
181
80
|
|
182
81
|
|
183
|
-
#
|
184
|
-
|
82
|
+
# Synchronously returns all described entries that are found in the cache,
|
83
|
+
# and a MultiQuery for the entries that are not there.
|
84
|
+
get_many: (multi_query) ->
|
85
|
+
@entry_store.get_many multi_query
|
185
86
|
|
186
|
-
# Try to load from cache.
|
187
|
-
return success_callback(entry) if entry = @get key
|
188
87
|
|
189
|
-
|
190
|
-
|
88
|
+
# Returns the described entry from any available data source.
|
89
|
+
load: (query, callback) ->
|
90
|
+
query = @_querify_single query
|
91
|
+
if (entry = @get query)
|
92
|
+
callback entry
|
93
|
+
else
|
94
|
+
@server_api.read query, (server_response) =>
|
95
|
+
@add_to_cache server_response[@entry_name]
|
96
|
+
callback @get(server_response)
|
191
97
|
|
192
98
|
|
193
|
-
# Loads all entries
|
194
|
-
load_many: (
|
195
|
-
|
196
|
-
if
|
99
|
+
# Loads all described entries from any available data source.
|
100
|
+
load_many: (multi_query, callback) ->
|
101
|
+
cache_result = @get_many multi_query
|
102
|
+
if cache_result.missing.empty()
|
197
103
|
# All requested entries found in cache --> return them immediately.
|
198
|
-
|
104
|
+
callback cache_result.found
|
199
105
|
else
|
200
|
-
#
|
201
|
-
@
|
202
|
-
|
106
|
+
# Some entries were not found in the cache --> load them from the server.
|
107
|
+
@server_api.read_many cache_result.missing, (server_response) =>
|
108
|
+
@add_many_to_cache server_response[@entries_name]
|
109
|
+
$.merge cache_result.found, @get_many(server_response).found
|
110
|
+
callback cache_result.found
|
203
111
|
|
204
112
|
|
205
|
-
#
|
206
|
-
#
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
@
|
211
|
-
|
212
|
-
@create obj, success_callback, error_callback
|
213
|
-
|
113
|
+
# Merges the entries described by the given ids
|
114
|
+
# into a new entry with the given data.
|
115
|
+
merge: (old_entry_ids, new_entry_data, callback) ->
|
116
|
+
@server_api.merge old_entry_ids, new_entry_data, (server_response) =>
|
117
|
+
@entry_store.delete_many ids: old_entry_ids
|
118
|
+
@entry_store.add server_response[@entry_name]
|
119
|
+
callback @get(server_response)
|
214
120
|
|
215
|
-
# TODO: save_many
|
216
121
|
|
217
122
|
# Updates the given object.
|
218
123
|
#
|
219
|
-
# The given object must exist on the server
|
220
|
-
# and have a proper value in the
|
221
|
-
update: (
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
# Send to server
|
233
|
-
data = {}
|
234
|
-
data[@model_name] = diff_obj
|
235
|
-
jQuery.ajax
|
236
|
-
url: @entry_url(obj)
|
237
|
-
type: 'PUT'
|
238
|
-
data: data
|
239
|
-
success: (server_response) =>
|
240
|
-
@client_entry = @add server_response[@model_name]
|
241
|
-
success_callback @client_entry if success_callback
|
242
|
-
error: (xhr) ->
|
243
|
-
error_callback(xhr.responseText) if error_callback
|
124
|
+
# The given object must already exist on the server,
|
125
|
+
# and have a proper value in the id attribute.
|
126
|
+
update: (entry, callback) ->
|
127
|
+
if (changes = @entry_store.entry_changes entry)
|
128
|
+
# There are changes --> update the server.
|
129
|
+
@server_api.update changes, (server_response) =>
|
130
|
+
@entry_store.add server_response[@entry_name]
|
131
|
+
callback(server_response) if callback
|
132
|
+
else
|
133
|
+
# No changes --> call the callback directly.
|
134
|
+
callback_data = {}
|
135
|
+
callback_data[@entry_name] = entry
|
136
|
+
callback(callback_data) if callback
|
244
137
|
|
245
138
|
|
246
139
|
# Bulk-updates the given objects.
|
247
|
-
# All the existing objects must exist on the server
|
248
|
-
# and have a value in the
|
249
|
-
update_many: (
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
type: 'PUT'
|
260
|
-
data: data
|
261
|
-
success: (server_response) =>
|
262
|
-
server_objects = server_response["#{@model_name}s"]
|
263
|
-
client_objects = (for server_object in server_objects
|
264
|
-
@server_data.add server_object
|
265
|
-
client_object = slender_data.clone_hash server_object
|
266
|
-
@client_data.add client_object
|
267
|
-
client_object)
|
268
|
-
success_callback(client_objects) if success_callback
|
269
|
-
error: (xhr) ->
|
270
|
-
error_callback(xhr.responseText) if error_callback
|
140
|
+
# All the existing objects must already exist on the server,
|
141
|
+
# and have a value in the id attribute.
|
142
|
+
update_many: (entries, callback) ->
|
143
|
+
if (changes = @entry_store.entries_changes entries).length > 0
|
144
|
+
# There are changes --> update the server.
|
145
|
+
@server_api.update_many changes, (server_response) =>
|
146
|
+
@entry_store.add_many server_response[@entries_name]
|
147
|
+
callback(server_response) if callback
|
148
|
+
else
|
149
|
+
callback_data = {}
|
150
|
+
callback_data[@entries_name] = entries
|
151
|
+
callback(callback_data) if callback
|
271
152
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#= require slender_data/parameterizable
|
2
|
+
|
3
|
+
|
4
|
+
# Abstract base class for queries.
|
5
|
+
class slender_data.BaseQuery extends slender_data.Parameterizable
|
6
|
+
|
7
|
+
# query_data: a hash containing the data of the query.
|
8
|
+
constructor: (query_data, params) ->
|
9
|
+
super params
|
10
|
+
|
11
|
+
# Whether to return only full entries.
|
12
|
+
#
|
13
|
+
# If false, partial entries are also permitted as results.
|
14
|
+
@full = query_data.full
|
15
|
+
|
16
|
+
# The query that was given in the constructor.
|
17
|
+
@given_query = query_data
|
18
|
+
|
19
|
+
|
20
|
+
# Returns the key used in the given query.
|
21
|
+
selector_name: ->
|
22
|
+
@_selector_name_result or= Object.keys(@given_query)[0]
|
23
|
+
|
24
|
+
|
25
|
+
# Returns the given selector value.
|
26
|
+
selector_value: ->
|
27
|
+
@given_query[@selector_name()]
|
28
|
+
|
29
|
+
|
30
|
+
# Returns the hash representation of this query.
|
31
|
+
to_hash: ->
|
32
|
+
@given_query
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#= require slender_data/queries/base_query
|
2
|
+
#= require slender_data/queries/single_query
|
3
|
+
|
4
|
+
|
5
|
+
# Represents a query for multiple entries at once.
|
6
|
+
class slender_data.MultiQuery extends slender_data.BaseQuery
|
7
|
+
|
8
|
+
constructor: (query, params) ->
|
9
|
+
super query, params
|
10
|
+
|
11
|
+
# Cache for the currently known entry ids of this query.
|
12
|
+
# If undefined, this value will be calculated later on demand.
|
13
|
+
#
|
14
|
+
# Don't use this field directly. Use ids() to access it.
|
15
|
+
@_ids_value = undefined
|
16
|
+
|
17
|
+
# Cache for the currently known entries of this query.
|
18
|
+
# If undefined, this value will be calculated later on demand.
|
19
|
+
#
|
20
|
+
# Don't use this field directly. Use entries() to access it.
|
21
|
+
@_entries_value = undefined
|
22
|
+
|
23
|
+
@_store_multi_query query
|
24
|
+
|
25
|
+
# Allows to access the entries through their domain name,
|
26
|
+
# i.e. @users()
|
27
|
+
@[@entries_name] = @entries
|
28
|
+
|
29
|
+
# Allows to access the entry ids through their domain name,
|
30
|
+
# i.e. usernames()
|
31
|
+
@[@ids_name] = @ids
|
32
|
+
|
33
|
+
|
34
|
+
# Returns whether this multi-query describes no entries.
|
35
|
+
empty: ->
|
36
|
+
@ids().length is 0
|
37
|
+
|
38
|
+
|
39
|
+
# Returns the corresponding entries for this query.
|
40
|
+
entries: ->
|
41
|
+
@_entries_value or throw new Error("Cannot provide #{@entries_name} for a #{@ids_name} query")
|
42
|
+
|
43
|
+
|
44
|
+
# Returns the ids for this query.
|
45
|
+
ids: ->
|
46
|
+
@_ids_value or= (entry[@id_name] for entry in @entries())
|
47
|
+
|
48
|
+
|
49
|
+
# Creates a new MultiQuery with the same configuration as this one,
|
50
|
+
# but the given selector value.
|
51
|
+
replicate: (new_selector_value) ->
|
52
|
+
replica_query = slender_data.clone_hash @given_query
|
53
|
+
replica_query[@selector_name()] = new_selector_value
|
54
|
+
new @multi_query_class replica_query, @params
|
55
|
+
|
56
|
+
|
57
|
+
# Converts the given multi-key name into the corresponding single key name.
|
58
|
+
single_selector_name: ->
|
59
|
+
unless @_single_selector_name_result
|
60
|
+
if @selector_name() is @entries_name
|
61
|
+
@_single_selector_name_result = @entry_name
|
62
|
+
else
|
63
|
+
@_single_selector_name_result = @selector_name().substring 0, @selector_name().length-1
|
64
|
+
@_single_selector_name_result
|
65
|
+
|
66
|
+
|
67
|
+
# Stores the given data.
|
68
|
+
_store_multi_query: (multi_query) ->
|
69
|
+
switch @selector_name()
|
70
|
+
when 'entries'
|
71
|
+
@_entries_value = multi_query.entries
|
72
|
+
when @entries_name
|
73
|
+
@_entries_value = multi_query[@entries_name]
|
74
|
+
when 'ids'
|
75
|
+
@_ids_value = multi_query.ids
|
76
|
+
when @ids_name
|
77
|
+
@_ids_value = multi_query[@ids_name]
|
78
|
+
else
|
79
|
+
throw new Error("Unknown multi-query key name: #{@selector_name()}")
|
80
|
+
|
81
|
+
|
82
|
+
# Converts the given multi-query into an array of single queries.
|
83
|
+
transpose: ->
|
84
|
+
result = []
|
85
|
+
for selector in @selector_value()
|
86
|
+
single_query = {}
|
87
|
+
single_query[@single_selector_name()] = selector
|
88
|
+
single_query.full = yes if @full
|
89
|
+
result.push new @single_query_class(single_query, @params)
|
90
|
+
result
|
91
|
+
|