Module: Rhoconnect::Handler::Changes::ExecuteMethods
- Included in:
- Server
- Defined in:
- lib/rhoconnect/handler/changes/execute_methods.rb
Instance Method Summary collapse
- #_extract_cud_params ⇒ Object
-
#_run_cud_handler(route_handler, operations = ['create', 'update', 'delete']) ⇒ Object
encapsulate common code.
-
#execute_create_handler(route_handler) ⇒ Object
individual filters.
-
#execute_cud_handler(route_handler) ⇒ Object
combined CUD filter (aka ‘queue_updates’).
- #execute_delete_handler(route_handler) ⇒ Object
- #execute_update_handler(route_handler) ⇒ Object
Instance Method Details
#_extract_cud_params ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 70 def _extract_cud_params begin if params["cud"] cud = JSON.parse(params["cud"]) params.delete("cud") params.merge!(cud) end rescue JSON::ParserError => jpe log jpe. + jpe.backtrace.join("\n") throw :halt, [500, "Server error while processing client data"] rescue Exception => e log e. + e.backtrace.join("\n") throw :halt, [500, "Internal server error"] end end |
#_run_cud_handler(route_handler, operations = ['create', 'update', 'delete']) ⇒ Object
encapsulate common code
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 54 def _run_cud_handler(route_handler, operations = ['create', 'update', 'delete']) @handler = nil if operations.is_a?String operations = [operations] end if not current_source.is_pass_through? @handler = Rhoconnect::Handler::Changes::Runner.new(operations, @model, current_client, route_handler, params) else @handler = Rhoconnect::Handler::Changes::PassThroughRunner.new(operations, @model, current_client, route_handler, params) end catch_all do @handler.run end status 200 end |
#execute_create_handler(route_handler) ⇒ Object
individual filters
13 14 15 16 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 13 def execute_create_handler(route_handler) _extract_cud_params _run_cud_handler(route_handler, 'create') end |
#execute_cud_handler(route_handler) ⇒ Object
combined CUD filter (aka ‘queue_updates’)
7 8 9 10 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 7 def execute_cud_handler(route_handler) _extract_cud_params _run_cud_handler(route_handler) end |
#execute_delete_handler(route_handler) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 38 def execute_delete_handler(route_handler) begin obj = current_client.get_object(:cd, params[:id]) params.merge!("delete" => { params[:id] => obj } ) rescue JSON::ParserError => jpe log jpe. + jpe.backtrace.join("\n") throw :halt, [500, "Server error while processing client data"] rescue Exception => e log e. + e.backtrace.join("\n") throw :halt, [500, "Internal server error"] end _run_cud_handler(route_handler, 'delete') end |
#execute_update_handler(route_handler) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rhoconnect/handler/changes/execute_methods.rb', line 18 def execute_update_handler(route_handler) _extract_cud_params # merge specific 'update' params begin if params["update"] cud = params["update"] params.delete("update") params.merge!("update" => {params[:id] => cud}) end rescue JSON::ParserError => jpe log jpe. + jpe.backtrace.join("\n") throw :halt, [500, "Server error while processing client data"] rescue Exception => e log e. + e.backtrace.join("\n") throw :halt, [500, "Internal server error"] end _run_cud_handler(route_handler, 'update') end |