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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.yardopts +1 -0
- data/API.md +62 -0
- data/Gemfile +2 -0
- data/JSON_format.md +62 -0
- data/PubSub.md +20 -0
- data/README.md +2 -0
- data/Security.md +0 -0
- data/docs/HyperRecord/ClassMethods.html +2969 -0
- data/docs/HyperRecord/ClientInstanceMethods.html +1833 -0
- data/docs/HyperRecord/Collection.html +564 -0
- data/docs/HyperRecord/DummyValue.html +384 -0
- data/docs/HyperRecord/PubSub/ClassMethods.html +2047 -0
- data/docs/HyperRecord/PubSub.html +1679 -0
- data/docs/HyperRecord/ServerClassMethods.html +697 -0
- data/docs/HyperRecord.html +119 -0
- data/docs/Hyperloop/Resource/ClientDrivers.html +352 -0
- data/docs/Hyperloop/Resource/HTTP.html +1795 -0
- data/docs/Hyperloop/Resource/MethodsController.html +479 -0
- data/docs/Hyperloop/Resource/PropertiesController.html +225 -0
- data/docs/Hyperloop/Resource/PubSub/ClassMethods.html +105 -0
- data/docs/Hyperloop/Resource/PubSub.html +1210 -0
- data/docs/Hyperloop/Resource/RelationsController.html +529 -0
- data/docs/Hyperloop/Resource/ScopesController.html +380 -0
- data/docs/Hyperloop/Resource/SecurityError.html +124 -0
- data/docs/Hyperloop/Resource/SecurityGuards/ClassMethods.html +226 -0
- data/docs/Hyperloop/Resource/SecurityGuards.html +299 -0
- data/docs/Hyperloop/Resource.html +135 -0
- data/docs/Hyperloop.html +186 -0
- data/docs/_index.html +302 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.API.html +138 -0
- data/docs/file.JSON_format.html +134 -0
- data/docs/file.PubSub.html +86 -0
- data/docs/file.README.html +192 -0
- data/docs/file_list.html +71 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +192 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1115 -0
- data/docs/top-level-namespace.html +110 -0
- data/hyper-resource.gemspec +19 -18
- data/lib/hyper_record/class_methods.rb +186 -3
- data/lib/hyper_record/client_instance_methods.rb +68 -3
- data/lib/hyper_record/collection.rb +19 -4
- data/lib/hyper_record/pub_sub.rb +92 -12
- data/lib/hyper_record/server_class_methods.rb +15 -0
- data/lib/hyperloop/resource/client_drivers.rb +2 -0
- data/lib/hyperloop/resource/http.rb +33 -22
- data/lib/hyperloop/resource/pub_sub.rb +2 -0
- data/lib/hyperloop/resource/version.rb +1 -1
- metadata +61 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89583b7e921ac559d94a7edba949cc461de7ae50cf0ad84f88814fa340001e96
|
4
|
+
data.tar.gz: ae6d2726d65ea5ac78f606aa48a2f913d6a19383e3f2470a4e6898f4f664282d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c41fea889711dcbaae760a80c43b985188fddd0c1aeb363bc15c4b7c8ca48f32585f358fb43ed232bed52df01f6248dd2ba82459a50651ffa44ae1bcf798ab3b
|
7
|
+
data.tar.gz: e71449e31b590f2ea670433d77e339305c1201a52c205ac83813dcfc03796b6f223db45b07cb82bfc0cd9227b52f2991abd2cc9e53d0cdbc1ac23d5afd58d9d5
|
data/.gitignore
ADDED
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
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
|