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: 5268ebb83d342ead93ab66794ca07a8a628f24a3
4
- data.tar.gz: ec2ec4005fdd30adc7a04c5e10a36a3587611c47
3
+ metadata.gz: 3a78e8a3fdf1f007bb043768e350f5cb1eaada4b
4
+ data.tar.gz: bbe127c27616580698c42ad4e194e280bb13c97f
5
5
  SHA512:
6
- metadata.gz: ce99cc731d29ec1fb62f69c54422bed0c9f652e3918700279066076a374790ec83c1e2678b07c2de2edd9b49f8a8e91c945c98c1574a492f668bd797c221b54e
7
- data.tar.gz: 4d8f8c51d36cea8c292946052a73dabb232c8ac9db47cffc900833aa8694d7e2a12c5c1b58606440d0137abd79655dd45d336636c46b82c94d60910582169ae8
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
- raise AccessViolation unless _Railway.params_wrapper.method_defined? security_param
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, parsed_params[:operation], parsed_params[:params].merge(acting_user: 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
@@ -1,5 +1,5 @@
1
1
  module Hyperloop
2
2
  class Operation
3
- VERSION = '0.5.10'
3
+ VERSION = '0.5.11'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyper-operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - catmando