hyper-mesh 1.0.0.lap26 → 1.0.0.lap27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/hyper-mesh.rb +1 -0
- data/lib/hypermesh/version.rb +1 -1
- data/lib/reactive_record/active_record/instance_methods.rb +10 -0
- data/lib/reactive_record/active_record/reactive_record/backing_record_inspector.rb +39 -0
- data/lib/reactive_record/active_record/reactive_record/base.rb +3 -2
- data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +2 -2
- data/lib/reactive_record/active_record/reactive_record/operations.rb +48 -3
- data/lib/reactive_record/permissions.rb +0 -8
- data/lib/reactive_record/pry.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae2e1bd29b4c0fd94efb2466949a271d478a5585d2e81045e88871c02e412256
|
4
|
+
data.tar.gz: abf0a91cc51d3b62e3053392082b0df4a1f80113bb0cd3d8876aca6fbb994a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7867946eaf76d99ef08323ccbf6c78fe20c7cb440e4cbe43b379bbd34e5ea168808b3d525c8649ce04f20e5ea37f196b6b1a1b0f7a0bca849abbbc14373c97f5
|
7
|
+
data.tar.gz: 820061867257b00bb28cedfc11212e3f5d0a28439a1080c0aca2651977673ea13eb9a6d997fca5a7b4dd333ffa1f88ceca07daa4923f7ed682c2b2a6ccf42156
|
data/Gemfile
CHANGED
data/lib/hyper-mesh.rb
CHANGED
@@ -17,6 +17,7 @@ if RUBY_ENGINE == 'opal'
|
|
17
17
|
require 'reactive_record/active_record/reactive_record/column_types'
|
18
18
|
require "reactive_record/active_record/aggregations"
|
19
19
|
require "reactive_record/active_record/associations"
|
20
|
+
require "reactive_record/active_record/reactive_record/backing_record_inspector"
|
20
21
|
require "reactive_record/active_record/reactive_record/base"
|
21
22
|
require "reactive_record/active_record/reactive_record/reactive_set_relationship_helpers"
|
22
23
|
require "reactive_record/active_record/reactive_record/collection"
|
data/lib/hypermesh/version.rb
CHANGED
@@ -2,6 +2,12 @@ module ActiveRecord
|
|
2
2
|
|
3
3
|
module InstanceMethods
|
4
4
|
|
5
|
+
def inspect
|
6
|
+
"<#{model_name}:#{ReactiveRecord::Operations::Base::FORMAT % to_key} "\
|
7
|
+
"(#{ReactiveRecord::Operations::Base::FORMAT % object_id}) "\
|
8
|
+
"#{backing_record.inspection_details} >"
|
9
|
+
end
|
10
|
+
|
5
11
|
attr_reader :backing_record
|
6
12
|
|
7
13
|
def attributes
|
@@ -167,6 +173,10 @@ module ActiveRecord
|
|
167
173
|
@backing_record.errors
|
168
174
|
end
|
169
175
|
|
176
|
+
def to_key
|
177
|
+
@backing_record.object_id
|
178
|
+
end
|
179
|
+
|
170
180
|
def update_attribute(attr, value, &block)
|
171
181
|
send("#{attr}=", value)
|
172
182
|
save(validate: false, &block)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ReactiveRecord
|
2
|
+
# inspection_details is used by client side ActiveRecord::Base
|
3
|
+
# runs down the possible states of a backing record and returns
|
4
|
+
# the appropriate string. The order of execution is important!
|
5
|
+
module BackingRecordInspector
|
6
|
+
def inspection_details
|
7
|
+
return error_details unless errors.empty?
|
8
|
+
return new_details if new?
|
9
|
+
return destroyed_details if destroyed
|
10
|
+
return loading_details unless attributes.key? primary_key
|
11
|
+
return dirty_details unless changed_attributes.empty?
|
12
|
+
"[loaded id: #{id}]"
|
13
|
+
end
|
14
|
+
|
15
|
+
def error_details
|
16
|
+
id_str = "id: #{id} " unless new?
|
17
|
+
"[errors #{id_str}#{errors.messages}]"
|
18
|
+
end
|
19
|
+
|
20
|
+
def new_details
|
21
|
+
"[new #{attributes.select { |attr| column_type(attr) }}]"
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroyed_details
|
25
|
+
"[destroyed id: #{id}]"
|
26
|
+
end
|
27
|
+
|
28
|
+
def loading_details
|
29
|
+
"[loading #{vector}]"
|
30
|
+
end
|
31
|
+
|
32
|
+
def dirty_details
|
33
|
+
changes = Hash[changed_attributes.collect do |attr|
|
34
|
+
[attr, [@synced_attributes[attr], attributes[attr]]] if column_type(attr)
|
35
|
+
end.compact]
|
36
|
+
"[changed id: #{id} #{changes}]"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module ReactiveRecord
|
2
2
|
class Base
|
3
|
+
include BackingRecordInspector
|
3
4
|
|
4
5
|
# Its all about lazy loading. This prevents us from grabbing enormous association collections, or large attributes
|
5
6
|
# unless they are explicitly requested.
|
@@ -344,7 +345,7 @@ module ReactiveRecord
|
|
344
345
|
|
345
346
|
def errors!(errors)
|
346
347
|
@saving = false
|
347
|
-
@errors = errors
|
348
|
+
@errors = errors && ActiveModel::Error.new(errors)
|
348
349
|
end
|
349
350
|
|
350
351
|
def saved! # sets saving to false AND notifies
|
@@ -363,7 +364,7 @@ module ReactiveRecord
|
|
363
364
|
end
|
364
365
|
|
365
366
|
def new?
|
366
|
-
!id
|
367
|
+
!id && !vector
|
367
368
|
end
|
368
369
|
|
369
370
|
def find_association(association, id)
|
@@ -491,7 +491,7 @@ module ReactiveRecord
|
|
491
491
|
end
|
492
492
|
|
493
493
|
rescue Exception => e
|
494
|
-
ReactiveRecord::Pry.rescued(e)
|
494
|
+
#ReactiveRecord::Pry.rescued(e)
|
495
495
|
if save
|
496
496
|
{success: false, saved_models: saved_models, message: e}
|
497
497
|
else
|
@@ -554,7 +554,7 @@ module ReactiveRecord
|
|
554
554
|
{success: true, attributes: {}}
|
555
555
|
|
556
556
|
rescue Exception => e
|
557
|
-
ReactiveRecord::Pry.rescued(e)
|
557
|
+
#ReactiveRecord::Pry.rescued(e)
|
558
558
|
{success: false, record: record, message: e}
|
559
559
|
end
|
560
560
|
end
|
@@ -2,11 +2,56 @@ module ReactiveRecord
|
|
2
2
|
# redefine if you want to process errors (i.e. logging, rollbar, etc)
|
3
3
|
def self.on_fetch_error(e, params); end
|
4
4
|
|
5
|
+
# associations: {parent_id: record.object_id, attribute: attribute, child_id: assoc_record.object_id}
|
6
|
+
# models: {id: record.object_id, model: record.model.model_name, attributes: changed_attributes}
|
7
|
+
|
5
8
|
module Operations
|
9
|
+
# to make debug easier we convert all the object_id strings to be hex representation
|
10
|
+
class Base < Hyperloop::ControllerOp
|
11
|
+
param :acting_user, nils: true
|
12
|
+
|
13
|
+
FORMAT = '0x%x'
|
14
|
+
|
15
|
+
def self.serialize_params(hash)
|
16
|
+
hash['associations'].each do |assoc|
|
17
|
+
assoc['parent_id'] = FORMAT % assoc['parent_id']
|
18
|
+
assoc['child_id'] = FORMAT % assoc['child_id']
|
19
|
+
end if hash['associations']
|
20
|
+
hash['models'].each do |assoc|
|
21
|
+
assoc['id'] = FORMAT % assoc[:id]
|
22
|
+
end if hash['models']
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.deserialize_params(hash)
|
27
|
+
hash['associations'].each do |assoc|
|
28
|
+
assoc['parent_id'] = assoc['parent_id'].to_i(16)
|
29
|
+
assoc['child_id'] = assoc['child_id'].to_i(16)
|
30
|
+
end if hash['associations']
|
31
|
+
hash['models'].each do |assoc|
|
32
|
+
assoc['id'] = assoc['id'].to_i(16)
|
33
|
+
end if hash['models']
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.serialize_response(response)
|
38
|
+
response[:saved_models].each do |saved_model|
|
39
|
+
saved_model[0] = FORMAT % saved_model[0]
|
40
|
+
end if response.is_a?(Hash) && response[:saved_models]
|
41
|
+
response
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.deserialize_response(response)
|
45
|
+
response[:saved_models].each do |saved_model|
|
46
|
+
saved_model[0] = saved_model[0].to_i(16)
|
47
|
+
end if response.is_a?(Hash) && response[:saved_models]
|
48
|
+
response
|
49
|
+
end
|
50
|
+
end
|
6
51
|
# fetch queued up records from the server
|
7
52
|
# subclass of ControllerOp so we can pass the controller
|
8
53
|
# along to on_fetch_error
|
9
|
-
class Fetch <
|
54
|
+
class Fetch < Base
|
10
55
|
param :acting_user, nils: true
|
11
56
|
param models: []
|
12
57
|
param associations: []
|
@@ -25,7 +70,7 @@ module ReactiveRecord
|
|
25
70
|
end
|
26
71
|
end
|
27
72
|
|
28
|
-
class Save <
|
73
|
+
class Save < Base
|
29
74
|
param :acting_user, nils: true
|
30
75
|
param models: []
|
31
76
|
param associations: []
|
@@ -42,7 +87,7 @@ module ReactiveRecord
|
|
42
87
|
end
|
43
88
|
end
|
44
89
|
|
45
|
-
class Destroy <
|
90
|
+
class Destroy < Base
|
46
91
|
param :acting_user, nils: true
|
47
92
|
param :model
|
48
93
|
param :id
|
data/lib/reactive_record/pry.rb
CHANGED
@@ -3,7 +3,7 @@ module ReactiveRecord
|
|
3
3
|
module Pry
|
4
4
|
|
5
5
|
def self.rescued(e)
|
6
|
-
if defined?(PryRescue) && e.instance_variable_defined?(:@rescue_bindings) && !e.is_a?(
|
6
|
+
if defined?(PryRescue) && e.instance_variable_defined?(:@rescue_bindings) && !e.is_a?(Hyperloop::AccessViolation)
|
7
7
|
::Pry::rescued(e)
|
8
8
|
end
|
9
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-mesh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.lap27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-03-
|
12
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -31,28 +31,28 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.0.0.
|
34
|
+
version: 1.0.0.lap27
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.0.0.
|
41
|
+
version: 1.0.0.lap27
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: hyper-operation
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.0.0.
|
48
|
+
version: 1.0.0.lap27
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.0.0.
|
55
|
+
version: 1.0.0.lap27
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - '='
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.0.0.
|
132
|
+
version: 1.0.0.lap27
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - '='
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.0.0.
|
139
|
+
version: 1.0.0.lap27
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: hyper-trace
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -608,6 +608,7 @@ files:
|
|
608
608
|
- lib/reactive_record/active_record/error.rb
|
609
609
|
- lib/reactive_record/active_record/instance_methods.rb
|
610
610
|
- lib/reactive_record/active_record/public_columns_hash.rb
|
611
|
+
- lib/reactive_record/active_record/reactive_record/backing_record_inspector.rb
|
611
612
|
- lib/reactive_record/active_record/reactive_record/base.rb
|
612
613
|
- lib/reactive_record/active_record/reactive_record/collection.rb
|
613
614
|
- lib/reactive_record/active_record/reactive_record/column_types.rb
|