hyper-resource 1.0.0.lap79 → 1.0.0.lap80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,6 +1,9 @@
1
1
  module HyperRecord
2
2
  module ClientInstanceMethods
3
3
 
4
+ # initialize a new instance of current HyperRecord class
5
+ #
6
+ # @param record_hash [Hash] optional, initial values for properties
4
7
  def initialize(record_hash = {})
5
8
  # initalize internal data structures
6
9
  record_hash = {} if record_hash.nil?
@@ -57,23 +60,40 @@ module HyperRecord
57
60
  self.class._record_cache[@properties[:id].to_s] = self if @properties.has_key?(:id)
58
61
  end
59
62
 
60
- ### reactive api
63
+ ### high level api
61
64
 
65
+ # destroy record, success is assumed
66
+ #
67
+ # @return nil
62
68
  def destroy
63
69
  promise_destroy
64
70
  nil
65
71
  end
66
72
 
73
+ # check if record has been destroyed
74
+ #
75
+ # @return [Boolean]
67
76
  def destroyed?
68
77
  @destroyed
69
78
  end
70
79
 
80
+ # link the two records using a relation determined by other_record.class, success is assumed
81
+ #
82
+ # @param other_record [HyperRecord]
83
+ # @return [HyperRecord] self
71
84
  def link(other_record)
72
85
  _register_observer
73
86
  promise_link(other_record)
74
87
  self
75
88
  end
76
89
 
90
+ # method_missing is used for undeclared properties like in ActiveRecord models
91
+ #
92
+ # Two call signatures:
93
+ # 1. the getter:
94
+ # a_model.a_undeclared_property, returns the value of a_undeclared_property
95
+ # 2. the setter:
96
+ # a_model.a_undeclared_property = value, set a_undeclared_property to value, returns value
77
97
  def method_missing(method, arg)
78
98
  _register_observer
79
99
  if method.end_with?('=')
@@ -87,25 +107,40 @@ module HyperRecord
87
107
  end
88
108
  end
89
109
 
110
+ # introspection
111
+ # @return [Hash]
90
112
  def reflections
91
113
  self.class.reflections
92
114
  end
93
115
 
116
+ # reset properties to last saved value
117
+ #
118
+ # @return [HyperRecord] self
94
119
  def reset
95
120
  _register_observer
96
121
  @changed_properties = {}
122
+ self
97
123
  end
98
124
 
125
+ # get the resource base uri that is used for api calls, used internally
126
+ #
127
+ # @return [String]
99
128
  def resource_base_uri
100
129
  self.class.resource_base_uri
101
130
  end
102
131
 
132
+ # save record to db, success is assumed
133
+ #
134
+ # @return [HyperRecord] self
103
135
  def save
104
136
  _register_observer
105
137
  promise_save
106
138
  self
107
139
  end
108
140
 
141
+ # return record properties as Hash
142
+ #
143
+ # @return [Hash]
109
144
  def to_hash
110
145
  _register_observer
111
146
  res = @properties.dup
@@ -113,11 +148,17 @@ module HyperRecord
113
148
  res
114
149
  end
115
150
 
151
+ # return record properties as String
152
+ #
153
+ # @return [String]
116
154
  def to_s
117
155
  _register_observer
118
156
  @properties.to_s
119
157
  end
120
158
 
159
+ # unlink the two records using a relation determined by other_record.class, success is assumed
160
+ #
161
+ # @return [HyperRecord] self
121
162
  def unlink(other_record)
122
163
  _register_observer
123
164
  promise_unlink(other_record)
@@ -126,9 +167,13 @@ module HyperRecord
126
167
 
127
168
  ### promise api
128
169
 
170
+ # destroy record
171
+ #
172
+ # @return [Promise] on success the record is passed to the .then block
173
+ # on failure the HTTP response is passed to the .fail block
129
174
  def promise_destroy
130
175
  _local_destroy
131
- self.class._promise_delete("#{resource_base_uri}/#{@properties[:id]}").then do |response|
176
+ self.class._promise_delete("#{resource_base_uri}/#{@properties[:id]}").then do |record|
132
177
  self
133
178
  end.fail do |response|
134
179
  error_message = "Destroying record #{self} failed!"
@@ -137,6 +182,11 @@ module HyperRecord
137
182
  end
138
183
  end
139
184
 
185
+ # link the two records using a relation determined by other_record.class
186
+ #
187
+ # @param other_record [HyperRecord]
188
+ # @return [Promise] on success the record is passed to the .then block
189
+ # on failure the HTTP response is passed to the .fail block
140
190
  def promise_link(other_record, relation_name = nil)
141
191
  called_from_collection = relation_name ? true : false
142
192
  relation_name = other_record.class.to_s.underscore.pluralize unless relation_name
@@ -174,6 +224,10 @@ module HyperRecord
174
224
  end
175
225
  end
176
226
 
227
+ # save record
228
+ #
229
+ # @return [Promise] on success the record is passed to the .then block
230
+ # on failure the HTTP response is passed to the .fail block
177
231
  def promise_save
178
232
  payload_hash = @properties.merge(@changed_properties) # copy hash, because we need to delete some keys
179
233
  (%i[id created_at updated_at] + reflections.keys).each do |key|
@@ -203,6 +257,11 @@ module HyperRecord
203
257
  end
204
258
  end
205
259
 
260
+ # unlink the two records using a relation determined by other_record.class
261
+ #
262
+ # @param other_record [HyperRecord]
263
+ # @return [Promise] on success the record is passed to the .then block
264
+ # on failure the HTTP response is passed to the .fail block
206
265
  def promise_unlink(other_record, relation_name = nil)
207
266
  called_from_collection = collection_name ? true : false
208
267
  relation_name = other_record.class.to_s.underscore.pluralize unless relation_name
@@ -210,6 +269,7 @@ module HyperRecord
210
269
  @relations[relation_name].delete_if { |cr| cr == other_record } if !called_from_collection && @fetch_states[relation_name] == 'f'
211
270
  self.class._promise_delete("#{resource_base_uri}/#{@properties[:id]}/relations/#{relation_name}.json?record_id=#{other_record.id}").then do |response|
212
271
  _notify_observers
272
+ other_record._notify_observers
213
273
  self
214
274
  end.fail do |response|
215
275
  error_message = "Unlinking #{other_record} from #{self} failed!"
@@ -219,7 +279,7 @@ module HyperRecord
219
279
  end
220
280
 
221
281
  ### internal
222
-
282
+ # @private
223
283
  def _local_destroy
224
284
  _register_observer
225
285
  @destroyed = true
@@ -231,6 +291,7 @@ module HyperRecord
231
291
  _notify_observers
232
292
  end
233
293
 
294
+ # @private
234
295
  def _notify_observers
235
296
  @observers.each do |observer|
236
297
  React::State.set_state(observer, @state_key, `Date.now() + Math.random()`)
@@ -239,10 +300,12 @@ module HyperRecord
239
300
  self.class._notify_class_observers
240
301
  end
241
302
 
303
+ # @private
242
304
  def _register_collection(collection)
243
305
  @registered_collections << collection
244
306
  end
245
307
 
308
+ # @private
246
309
  def _register_observer
247
310
  observer = React::State.current_observer
248
311
  if observer
@@ -251,10 +314,12 @@ module HyperRecord
251
314
  end
252
315
  end
253
316
 
317
+ # @private
254
318
  def _unregister_collection(collection)
255
319
  @registered_collections.delete(collection)
256
320
  end
257
321
 
322
+ # @private
258
323
  def _update_record(data)
259
324
  if data.has_key?(:relation)
260
325
  if data.has_key?(:cause)
@@ -1,17 +1,26 @@
1
1
  module HyperRecord
2
2
  class Collection < Array
3
- def initialize(array, record = nil, relation_name = nil)
3
+
4
+ # initialize new HyperRecord::Collection, used internally
5
+ #
6
+ # @param collection [HyperRecord::Collection] or [Array] of records or empty [Array]
7
+ # @param record [HyperRecord] optional base record this collection belongs to
8
+ # @param relation_name [String] optional base record relation name this collection represents
9
+ def initialize(collection = [], record = nil, relation_name = nil)
4
10
  @record = record
5
11
  @relation_name = relation_name
6
- if array
7
- array.each do |record|
12
+ if collection
13
+ collection.each do |record|
8
14
  record._register_collection(self)
9
15
  end
10
16
  end
11
17
  @record._notify_observers if @record
12
- array ? super(array) : super
18
+ collection ? super(collection) : super
13
19
  end
14
20
 
21
+ # add record to collection, record is saved to db, success assumed
22
+ #
23
+ # @param other_record [HyperRecord] record to add
15
24
  def <<(other_record)
16
25
  if @record && @relation_name
17
26
  @record.promise_link(other_record, @relation_name)
@@ -21,6 +30,9 @@ module HyperRecord
21
30
  super(other_record)
22
31
  end
23
32
 
33
+ # delete record from collection, saved to db, success assumed
34
+ #
35
+ # @param other_record [HyperRecord] record to delete from collection
24
36
  def delete(other_record)
25
37
  if @record && @relation_name && !other_record.instance_variable_get(:@remotely_destroyed)
26
38
  @record.promise_unlink(other_record, @relation_name)
@@ -30,6 +42,9 @@ module HyperRecord
30
42
  super(other_record)
31
43
  end
32
44
 
45
+ # add record to collection, not saved to db
46
+ #
47
+ # @param other_record [HyperRecord] record to add
33
48
  def push(other_record)
34
49
  other_record._register_collection(self)
35
50
  @record._notify_observers if @record
@@ -9,6 +9,7 @@ module HyperRecord
9
9
  module ClassMethods
10
10
  attr_accessor :policy_params
11
11
 
12
+ # @private
12
13
  def _pusher_client
13
14
  Hyperloop.pusher_instance ||= Pusher::Client.new(
14
15
  app_id: Hyperloop.pusher[:app_id],
@@ -18,6 +19,9 @@ module HyperRecord
18
19
  )
19
20
  end
20
21
 
22
+ # send message about record change to all subscribers of this record
23
+ #
24
+ # @param record of ORM specific type, record must respond to: id, updated_at, destroyed?
21
25
  def publish_record(record)
22
26
  subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}")
23
27
  time_now = Time.now.to_f
@@ -47,6 +51,11 @@ module HyperRecord
47
51
  Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
48
52
  end
49
53
 
54
+ # send message about relation change to all subscribers of this record
55
+ #
56
+ # @param base_record of ORM specific type, base_record must respond to: id, updated_at, destroyed?
57
+ # @param relation_name [String]
58
+ # @param record of ORM specific type, the record who causes the change, record must respond to: id, updated_at, destroyed?
50
59
  def publish_relation(base_record, relation_name, record = nil)
51
60
  subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}")
52
61
  time_now = Time.now.to_f
@@ -79,6 +88,10 @@ module HyperRecord
79
88
  end
80
89
  end
81
90
 
91
+ # send message to notify clients that they should call the rest_class_method again
92
+ #
93
+ # @param record_class ORM specific
94
+ # @param rest_class_method_name [String]
82
95
  def publish_rest_class_method(record_class, rest_class_method_name)
83
96
  subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
84
97
  time_now = Time.now.to_f
@@ -102,20 +115,24 @@ module HyperRecord
102
115
  end
103
116
  end
104
117
 
105
- def publish_rest_method(record, method_name)
106
- subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}")
118
+ # send message to notify clients that they should call the rest_method again
119
+ #
120
+ # @param record of ORM specific type
121
+ # @param rest_method_name [String]
122
+ def publish_rest_method(record, rest_method_name)
123
+ subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}")
107
124
  time_now = Time.now.to_f
108
125
  scrub_time = time_now - 24.hours.to_f
109
126
  message = {
110
127
  record_type: record.class.to_s,
111
128
  id: record.id,
112
- rest_method: method_name
129
+ rest_method: rest_method_name
113
130
  }
114
131
  subscribers.each_slice(10) do |slice|
115
132
  channel_array = []
116
133
  slice.each do |session_id, last_requested|
117
134
  if last_requested.to_f < scrub_time
118
- Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}", session_id)
135
+ Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id)
119
136
  next
120
137
  end
121
138
  channel_array << "hyper-record-update-channel-#{session_id}"
@@ -126,6 +143,10 @@ module HyperRecord
126
143
  end
127
144
  end
128
145
 
146
+ # send message about scope change to all subscribers
147
+ #
148
+ # @param record_class ORM specific
149
+ # @param scope_name [String]
129
150
  def publish_scope(record_class, scope_name)
130
151
  subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__scope__#{scope_name}")
131
152
  time_now = Time.now.to_f
@@ -149,11 +170,19 @@ module HyperRecord
149
170
  end
150
171
  end
151
172
 
173
+ # subscribe to record changes
174
+ #
175
+ # @param record of ORM specific type
152
176
  def subscribe_record(record)
153
177
  return unless session.id
154
178
  Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
155
179
  end
156
180
 
181
+ # subscribe to relation changes
182
+ #
183
+ # @param relation [Enumarable] or record of ORM specific type, subscribe to each member of relation
184
+ # @param base_record optional, of ORM specific type, subscribe to this base_record too
185
+ # @param relation_name [String] optional name of the relation
157
186
  def subscribe_relation(relation, base_record = nil, relation_name = nil)
158
187
  return unless session.id
159
188
  time_now = Time.now.to_f.to_s
@@ -172,6 +201,10 @@ module HyperRecord
172
201
  end
173
202
  end
174
203
 
204
+ # subscribe to rest_class_method updates
205
+ #
206
+ # @param record_class ORM specific
207
+ # @param rest_class_method_name [String] name of the rest_class_method
175
208
  def subscribe_rest_class_method(record_class, rest_class_method_name)
176
209
  return unless session.id
177
210
  time_now = Time.now.to_f.to_s
@@ -181,6 +214,10 @@ module HyperRecord
181
214
  end
182
215
  end
183
216
 
217
+ # subscribe to rest_method updates
218
+ #
219
+ # @param record of ORM specific type
220
+ # @param rest_method_name [String] name of the rest_method
184
221
  def subscribe_rest_method(record, rest_method_name)
185
222
  return unless session.id
186
223
  time_now = Time.now.to_f.to_s
@@ -188,6 +225,11 @@ module HyperRecord
188
225
  Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id, time_now)
189
226
  end
190
227
 
228
+ # subscribe to scope updates
229
+ #
230
+ # @param collection [Enumerable] subscribe to each member of collection
231
+ # @param record_class optional, ORM specific
232
+ # @param scope_name [String] optional
191
233
  def subscribe_scope(collection, record_class = nil, scope_name = nil)
192
234
  return unless session.id
193
235
  time_now = Time.now.to_f.to_s
@@ -202,94 +244,132 @@ module HyperRecord
202
244
  end
203
245
  end
204
246
 
247
+ # subscribe to record and then publish
248
+ #
249
+ # @param record of ORM psecific type
205
250
  def pub_sub_record(record)
206
251
  subscribe_record(record)
207
252
  publish_record(record)
208
253
  end
209
254
 
255
+ # subscribe to relation changes and then publish them
256
+ #
257
+ # @param relation [Enumarable] or record of ORM specific type, subscribe to each member of relation
258
+ # @param base_record of ORM specific type, base_record must respond to: id, updated_at, destroyed?
259
+ # @param relation_name [String]
260
+ # @param causing_record of ORM specific type the record who causes the change, reacord must respond to: id, updated_at, destroyed?
210
261
  def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
211
262
  subscribe_relation(relation, base_record, relation_name)
212
263
  publish_relation(base_record, relation_name, causing_record)
213
264
  end
214
265
 
266
+ # subscribe to rest_class_method and then send message to notify clients that
267
+ # they should call the rest_class_method again
268
+ #
269
+ # @param record_class ORM specific
270
+ # @param rest_class_method_name [String]
215
271
  def pub_sub_rest_class_method(record_class, rest_class_method_name)
216
272
  subscribe_rest_class_method(record_class, rest_class_method_name)
217
273
  publish_rest_class_method(record_class, rest_class_method_name)
218
274
  end
219
275
 
276
+ # subscribe to rest_method and then send message to notify clients that
277
+ # they should call the rest_method again
278
+ #
279
+ # @param record of ORM specific type
280
+ # @param rest_method_name [String]
220
281
  def pub_sub_rest_method(record, rest_method_name)
221
282
  subscribe_rest_method(record, rest_method_name)
222
283
  publish_rest_method(record, rest_method_name)
223
284
  end
224
285
 
286
+ # subscribe to scope changes and send message about scope change to all subscribers
287
+ #
288
+ # @param collection [Enumerable] subscribe to each member of collection
289
+ # @param record_class ORM specific
290
+ # @param scope_name [String]
225
291
  def pub_sub_scope(collection, record_class, scope_name)
226
292
  subscribe_scope(collection, record_class, scope_name)
227
293
  publish_scope(record_class, scope_name)
228
294
  end
229
295
 
296
+ # @private
230
297
  def session
231
298
  @_hyper_resource_session
232
299
  end
233
300
  end
234
301
 
235
- # instance methods
236
-
302
+ # (see ClassMethods#publish_record)
237
303
  def publish_record(record)
238
304
  self.class.publish_record(record)
239
305
  end
240
306
 
307
+ # (see ClassMethods#publish_relation)
241
308
  def publish_relation(base_record, relation_name, record = nil)
242
309
  self.class.publish_relation(base_record, relation_name, record)
243
310
  end
244
311
 
312
+ # (see ClassMethods#publish_rest_class_method)
245
313
  def publish_rest_class_method(record_class, rest_class_method_name)
246
314
  self.class.publish_rest_class_method(record_class, rest_class_method_name)
247
315
  end
248
316
 
249
- def publish_rest_method(record, method_name)
250
- self.class.publish_rest_method(record, method_name)
317
+ # (see ClassMethods#publish_rest_method)
318
+ def publish_rest_method(record, rest_method_name)
319
+ self.class.publish_rest_method(record, rest_method_name)
251
320
  end
252
321
 
322
+ # (see ClassMethods#publish_scope)
253
323
  def publish_scope(record_class, scope_name)
254
324
  self.class.publish_scope(record_class, scope_name)
255
325
  end
256
326
 
327
+ # (see ClassMethods#subscribe_record)
257
328
  def subscribe_record(record)
258
329
  self.class.subscribe_record(record)
259
330
  end
260
331
 
332
+ # (see ClassMethods#subscribe_relation)
261
333
  def subscribe_relation(relation, base_record = nil, relation_name = nil)
262
334
  self.class.subscribe_relation(relation, base_record, relation_name)
263
335
  end
264
336
 
337
+ # (see ClassMethods#subscribe_rest_class_method)
265
338
  def subscribe_rest_class_method(record_class, rest_class_method_name)
266
339
  self.class.subscribe_rest_class_method(record_class, rest_class_method_name)
267
340
  end
268
341
 
269
- def subscribe_rest_method(record, method_name)
270
- self.class.subscribe_rest_method(record, method_name)
342
+ # (see ClassMethods#subscribe_rest_method)
343
+ def subscribe_rest_method(record, rest_method_name)
344
+ self.class.subscribe_rest_method(record, rest_method_name)
271
345
  end
272
346
 
347
+ # (see ClassMethods#subscribe_scope)
273
348
  def subscribe_scope(collection, record_class = nil, scope_name = nil)
274
349
  self.class.subscribe_scope(collection, record_class, scope_name)
275
350
  end
276
351
 
352
+ # (see ClassMethods#pub_sub_record)
277
353
  def pub_sub_record(record)
278
354
  self.class.pub_sub_record(record)
279
355
  end
280
356
 
357
+ # (see ClassMethods#pub_sub_relation)
281
358
  def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
282
359
  self.class.pub_sub_relation(relation, base_record, relation_name, causing_record)
283
360
  end
284
361
 
362
+ # (see ClassMethods#pub_sub_rest_class_method)
285
363
  def pub_sub_rest_class_method(record_class, rest_class_method_name)
286
364
  self.class.pub_sub_rest_class_method(record_class, rest_class_method_name)
287
365
  end
288
366
 
289
- def pub_sub_rest_method(record, method_name)
290
- self.class.pub_sub_rest_method(record, method_name)
367
+ # (see ClassMethods#pub_sub_rest_method)
368
+ def pub_sub_rest_method(record, rest_method_name)
369
+ self.class.pub_sub_rest_method(record, rest_method_name)
291
370
  end
292
371
 
372
+ # (see ClassMethods#pub_sub_scope)
293
373
  def pub_sub_scope(collection, record_class, scope_name)
294
374
  self.class.pub_sub_scope(collection, record_class, scope_name)
295
375
  end
@@ -1,5 +1,8 @@
1
1
  module HyperRecord
2
2
  module ServerClassMethods
3
+ # DSL for defining rest_class_methods
4
+ # @param name [Symbol] name of the method
5
+ # @param options [Hash] known key: default_result, used client side
3
6
  def rest_class_method(name, options = { default_result: '...' }, &block)
4
7
  rest_class_methods[name] = options
5
8
  rest_class_methods[name][:params] = block.arity
@@ -12,6 +15,9 @@ module HyperRecord
12
15
  end
13
16
  end
14
17
 
18
+ # DSL for defining rest_methods
19
+ # @param name [Symbol] name of the method
20
+ # @param options [Hash] known key: default_result, used client side
15
21
  def rest_method(name, options = { default_result: '...' }, &block)
16
22
  rest_methods[name] = options
17
23
  rest_methods[name][:params] = block.arity
@@ -24,18 +30,27 @@ module HyperRecord
24
30
  end
25
31
  end
26
32
 
33
+ # introspect defined rest_class_methods
34
+ # @return [Hash]
27
35
  def rest_class_methods
28
36
  @rest_class_methods ||= {}
29
37
  end
30
38
 
39
+ # introspect defined rest_methods
40
+ # @return [Hash]
31
41
  def rest_methods
32
42
  @rest_methods ||= {}
33
43
  end
34
44
 
45
+ # introspect defined scopes
46
+ # @return [Hash]
35
47
  def resource_scopes
36
48
  @resource_scopes ||= []
37
49
  end
38
50
 
51
+ # defines a scope, wrapper around ORM method
52
+ # @param name [Symbol] name of the args
53
+ # @param *args additional args, passed to ORMs scope DSL
39
54
  def scope(name, *args)
40
55
  resource_scopes << name
41
56
  super(name, *args)
@@ -49,6 +49,7 @@ module Hyperloop
49
49
 
50
50
  else
51
51
 
52
+ # @private
52
53
  def self.initialize_client_drivers_on_boot
53
54
 
54
55
  return if @initialized
@@ -90,6 +91,7 @@ module Hyperloop
90
91
  end
91
92
  end
92
93
 
94
+ # @private
93
95
  def self.process_notification(data)
94
96
  record_class = Object.const_get(data[:record_type])
95
97
  if data[:scope]