hyper-operation 0.5.10 → 0.5.11
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a78e8a3fdf1f007bb043768e350f5cb1eaada4b
|
4
|
+
data.tar.gz: bbe127c27616580698c42ad4e194e280bb13c97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ee3c57e9825cffebaf783f108b10b241db6816fc8cc24edf9da5505d3508c2767b7c2eabdd68af08de85d62fb06a8fbf2e28486ccb0eca997c2a8b682df250f
|
7
|
+
data.tar.gz: 2267f2a8aa19cebc8bfcaaa772985cdc7790635ff902f2b51a4cc02aaf3af6dcfbde54e492d3ac50d967dae2164840af6dcc4a1be640c313441da285ef5bdf20
|
@@ -17,12 +17,16 @@ module Hyperloop
|
|
17
17
|
end
|
18
18
|
end if RUBY_ENGINE == 'opal'
|
19
19
|
|
20
|
-
def run_from_client(security_param, operation, params)
|
20
|
+
def run_from_client(security_param, controller, operation, params)
|
21
21
|
operation.constantize.class_eval do
|
22
|
-
|
22
|
+
if _Railway.params_wrapper.method_defined?(:controller)
|
23
|
+
params[:controller] = controller
|
24
|
+
elsif !_Railway.params_wrapper.method_defined?(security_param)
|
25
|
+
raise AccessViolation
|
26
|
+
end
|
23
27
|
run(params)
|
24
28
|
.then { |r| return { json: { response: serialize_response(r) } } }
|
25
|
-
.fail { |e| return { json: { error: e}, status: 500 } }
|
29
|
+
.fail { |e| return { json: { error: e }, status: 500 } }
|
26
30
|
end
|
27
31
|
rescue Exception => e
|
28
32
|
{ json: {error: e}, status: 500 }
|
@@ -95,4 +99,16 @@ module Hyperloop
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
end
|
102
|
+
|
103
|
+
class ControllerOp < ServerOp
|
104
|
+
param :controller
|
105
|
+
alias pre_controller_op_method_missing method_missing
|
106
|
+
def method_missing(name, *args, &block)
|
107
|
+
if params.controller.respond_to? name
|
108
|
+
params.controller.send(name, *args, &block)
|
109
|
+
else
|
110
|
+
pre_controller_op_method_missing(name, *args, &block)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
98
114
|
end
|
@@ -131,14 +131,18 @@ module Hyperloop
|
|
131
131
|
def execute_remote
|
132
132
|
parsed_params = JSON.parse(params[:json]).symbolize_keys
|
133
133
|
render ServerOp.run_from_client(
|
134
|
-
:acting_user,
|
134
|
+
:acting_user,
|
135
|
+
self,
|
136
|
+
parsed_params[:operation],
|
137
|
+
parsed_params[:params].merge(acting_user: acting_user)
|
138
|
+
)
|
135
139
|
end
|
136
140
|
|
137
141
|
def execute_remote_api
|
138
142
|
params.require(:params).permit!
|
139
143
|
parsed_params = params[:params].to_h.symbolize_keys
|
140
144
|
raise AccessViolation unless parsed_params[:authorization]
|
141
|
-
render ServerOp.run_from_client(:authorization, params[:operation], parsed_params)
|
145
|
+
render ServerOp.run_from_client(:authorization, self, params[:operation], parsed_params)
|
142
146
|
end
|
143
147
|
|
144
148
|
def console_update # TODO this should just become an execute-remote-api call
|