Method: Waxx::App#run

Defined in:
lib/waxx/app.rb

#run(x, app, act, meth, args) ⇒ Object

Run an app

Can run the request method (get post put patch delete) or the generic “run”.

  1. x

  2. app: The name of the app (Symbol)

  3. act: The act to run (String or Symbol - type must match definition)

4, meth: The request method (Symbol)

  1. args: The args to pass to the method (after x) (Array)

Example: ‘App.run(x, :person, :record, :get, [1])` will call the get method with the parameter “1” of the record handler defined in App::Person



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/waxx/app.rb', line 69

def run(x, app, act, meth, args)
  if @runs[app.to_sym][act][meth.to_sym]
    begin
      @runs[app.to_sym][act][meth.to_sym][x, *args]
    rescue ArgumentError => e
      if Waxx['debug']['on_screen']
        error(x, status: 405, type: "request", title: "Argument Error", message: "#{e.to_s}\n\n#{e.backtrace.join("\n")}")
      else
        Waxx.debug e
        App.not_found(x)
      end
    end
  elsif @runs[app.to_sym][act][:run]
    begin
      @runs[app.to_sym][act][:run][x, *args]
    rescue ArgumentError => e
      if Waxx['debug']['on_screen']
        error(x, status: 405, type: "request", title: "Argument Error", message: "#{e.to_s}\n\n#{e.backtrace.join("\n")}")
      else
        Waxx.debug e
        App.not_found(x)
      end
    end
  else
    error(x, status: 405, type: "request", title: "Method Not Implemented", message: "The HTTP method requested is not implemented for this interface.")
  end
end