hyper-resource 1.0.0.lap79 → 1.0.0.lap80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.yardopts +1 -0
  4. data/API.md +62 -0
  5. data/Gemfile +2 -0
  6. data/JSON_format.md +62 -0
  7. data/PubSub.md +20 -0
  8. data/README.md +2 -0
  9. data/Security.md +0 -0
  10. data/docs/HyperRecord/ClassMethods.html +2969 -0
  11. data/docs/HyperRecord/ClientInstanceMethods.html +1833 -0
  12. data/docs/HyperRecord/Collection.html +564 -0
  13. data/docs/HyperRecord/DummyValue.html +384 -0
  14. data/docs/HyperRecord/PubSub/ClassMethods.html +2047 -0
  15. data/docs/HyperRecord/PubSub.html +1679 -0
  16. data/docs/HyperRecord/ServerClassMethods.html +697 -0
  17. data/docs/HyperRecord.html +119 -0
  18. data/docs/Hyperloop/Resource/ClientDrivers.html +352 -0
  19. data/docs/Hyperloop/Resource/HTTP.html +1795 -0
  20. data/docs/Hyperloop/Resource/MethodsController.html +479 -0
  21. data/docs/Hyperloop/Resource/PropertiesController.html +225 -0
  22. data/docs/Hyperloop/Resource/PubSub/ClassMethods.html +105 -0
  23. data/docs/Hyperloop/Resource/PubSub.html +1210 -0
  24. data/docs/Hyperloop/Resource/RelationsController.html +529 -0
  25. data/docs/Hyperloop/Resource/ScopesController.html +380 -0
  26. data/docs/Hyperloop/Resource/SecurityError.html +124 -0
  27. data/docs/Hyperloop/Resource/SecurityGuards/ClassMethods.html +226 -0
  28. data/docs/Hyperloop/Resource/SecurityGuards.html +299 -0
  29. data/docs/Hyperloop/Resource.html +135 -0
  30. data/docs/Hyperloop.html +186 -0
  31. data/docs/_index.html +302 -0
  32. data/docs/class_list.html +51 -0
  33. data/docs/css/common.css +1 -0
  34. data/docs/css/full_list.css +58 -0
  35. data/docs/css/style.css +496 -0
  36. data/docs/file.API.html +138 -0
  37. data/docs/file.JSON_format.html +134 -0
  38. data/docs/file.PubSub.html +86 -0
  39. data/docs/file.README.html +192 -0
  40. data/docs/file_list.html +71 -0
  41. data/docs/frames.html +17 -0
  42. data/docs/index.html +192 -0
  43. data/docs/js/app.js +292 -0
  44. data/docs/js/full_list.js +216 -0
  45. data/docs/js/jquery.js +4 -0
  46. data/docs/method_list.html +1115 -0
  47. data/docs/top-level-namespace.html +110 -0
  48. data/hyper-resource.gemspec +19 -18
  49. data/lib/hyper_record/class_methods.rb +186 -3
  50. data/lib/hyper_record/client_instance_methods.rb +68 -3
  51. data/lib/hyper_record/collection.rb +19 -4
  52. data/lib/hyper_record/pub_sub.rb +92 -12
  53. data/lib/hyper_record/server_class_methods.rb +15 -0
  54. data/lib/hyperloop/resource/client_drivers.rb +2 -0
  55. data/lib/hyperloop/resource/http.rb +33 -22
  56. data/lib/hyperloop/resource/pub_sub.rb +2 -0
  57. data/lib/hyperloop/resource/version.rb +1 -1
  58. metadata +61 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9430772935e6c7baa1396aa73c09266072a6312a22fe66a51e50c7b01053e579
4
- data.tar.gz: 50f91a54c04446790d2dbc8a8f3d54abb0a554e4ab9860099ceab11e2b3e1807
3
+ metadata.gz: 89583b7e921ac559d94a7edba949cc461de7ae50cf0ad84f88814fa340001e96
4
+ data.tar.gz: ae6d2726d65ea5ac78f606aa48a2f913d6a19383e3f2470a4e6898f4f664282d
5
5
  SHA512:
6
- metadata.gz: 98c4f86d6fc72c03fa0892effa4b0c66a1751d6a32b856e1c218b16baf3034e3963b5c524b7665fe3adb9ea913930c32c562f0b64c8127bb48116efc5008dad6
7
- data.tar.gz: 5c69b6391ca3dcc1b22ad53c625f3c8f7c6041c025a7b5ac445cc1f6c946c9b8481e14221be7a68443fc648ca407a016fa8ae8555a0c4cefe6840c344f85c88a
6
+ metadata.gz: c41fea889711dcbaae760a80c43b985188fddd0c1aeb363bc15c4b7c8ca48f32585f358fb43ed232bed52df01f6248dd2ba82459a50651ffa44ae1bcf798ab3b
7
+ data.tar.gz: e71449e31b590f2ea670433d77e339305c1201a52c205ac83813dcfc03796b6f223db45b07cb82bfc0cd9227b52f2991abd2cc9e53d0cdbc1ac23d5afd58d9d5
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ .yardoc
3
+ Gemfile.lock
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --no-private -o docs - API.md JSON_format.md PubSub.md
data/API.md ADDED
@@ -0,0 +1,62 @@
1
+ Hyper-Resource provides two API levels
2
+
3
+ The high level API and the promise API
4
+
5
+ ## High level API
6
+
7
+ The high level api allows for a simple use of records and is in general recommended for read accesses. For write accesses, saving of data, the promise API is recommended, unless weather the data was saved or not is not of importance.
8
+
9
+ #### Schema of accessing data in the high level API:
10
+
11
+ ```
12
+ my_record = MyModel.find('1')
13
+ my_record.a_property
14
+ ```
15
+
16
+ 1. component is rendered
17
+ 2. during render a fetch is triggered
18
+ 2.1 component is registered as observer
19
+ 2.2 component gets dummy data to render
20
+ 3. render completes, data is fetched in the background
21
+ 4. when the data arrived
22
+ 4.1 the component as observer is notified
23
+ 4.2 a state change happens and the component is rendered again with the real data
24
+
25
+ #### Schema of saving data in the high level API
26
+
27
+ ```
28
+ my_record.a_property = 2
29
+ my_record.save
30
+ ```
31
+
32
+ Saving of data in the high level API is optimistic:
33
+
34
+ 1. triggering a save of data
35
+ 2. the method called returns immediately
36
+ 3. a successful save is assumed
37
+
38
+ ## Promise API
39
+
40
+ All methods of the promise API are prefixed by 'promise_', so instead of my_redord.save in the high level API, in the promise API one would use my_record.promise_save.
41
+ All methods in the promise API return a promise.
42
+ In general the pattern is:
43
+
44
+ ```
45
+ my_record.a_property = 2
46
+
47
+ my_record.promise_save.then do |record|
48
+ # save was successful
49
+ # do something here
50
+ end.fail do |response|
51
+ # save failed
52
+ # response is the http response object
53
+ end
54
+ ```
55
+
56
+ for example, finding a record:
57
+
58
+ ```
59
+ MyModel.promise_find('1').then do |record]
60
+ my_record.a_property
61
+ end
62
+ ```
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ gem 'opal-jquery', git: 'https://github.com/opal/opal-jquery.git', branch: 'master'
2
+ gemspec
data/JSON_format.md ADDED
@@ -0,0 +1,62 @@
1
+ ## JSON format
2
+
3
+ ### In case of a error:
4
+ ```json
5
+ {
6
+ "error": "error message"
7
+ }
8
+ ```
9
+ along with HTTP response status set accordingly
10
+
11
+ ### A single record
12
+ ```json
13
+ {
14
+ "record.class.to_s.underscore": {
15
+ "id": "a_string",
16
+ "updated_at": "time stamp, required at several places",
17
+ "further_properties": "at will"
18
+ }
19
+ }
20
+ ```
21
+
22
+ ### A relation
23
+ ```json
24
+ {
25
+ "record.class.to_s.underscore": {
26
+ "id": "a_string",
27
+ "relation_name": [
28
+ {
29
+ "member_record.class.to_s.underscore": {
30
+ "id": "a_string",
31
+ "further_properties": "at_will"
32
+ }
33
+ },
34
+ // further records ...
35
+ ]
36
+ }
37
+ }
38
+ ```
39
+
40
+ ### A scope
41
+ ```json
42
+ {
43
+ "record.class.to_s.underscore": {
44
+ "scope_name": [
45
+ {
46
+ "member_record.class.to_s.underscore": {
47
+ "id": "a_string",
48
+ "further_properties": "at_will"
49
+ }
50
+ },
51
+ // further records ...
52
+ ]
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### A rest_method or a rest_class_method
58
+ ```json
59
+ {
60
+ "result": result_value_or_object
61
+ }
62
+ ```
data/PubSub.md ADDED
@@ -0,0 +1,20 @@
1
+ ## PubSub with HyperResource
2
+
3
+ PubSub is handled in the controller. In your controller:
4
+ ```
5
+ include Hyperloop::Resource::PubSub
6
+ ```
7
+
8
+ Then you can use the PubSub methods of Hyperloop::Resource::PubSub.
9
+
10
+ For example, a record has been requested, subscribe to it in the show action of the controller:
11
+ ```
12
+ subscribe_record(my_record)
13
+ ```
14
+
15
+ When somebody updates the record, in the update action for example:
16
+ ```
17
+ publish_record(record)
18
+ ```
19
+
20
+ All subscribers will receive a message indicating, that the record has been updated.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # hyper-resource
2
2
 
3
+ [Github Repo](https://github.com/janbiedermann/hyper-resource "Github Repo")
4
+
3
5
  HyperResource is an affective way of moving data between your server and clients when using Hyperloop and Rails.
4
6
 
5
7
  [![Reactivity Demo](http://img.youtube.com/vi/fPSpESBbeMQ/0.jpg)](http://www.youtube.com/watch?v=fPSpESBbeMQ "Reactivity Demo")
data/Security.md ADDED
File without changes