class Pepito::HTTPApi::HTTPCallback
Class to help callback functions for the http routes
Attributes
func[R]
The function to call @return [Symbol]
klass[R]
The class to call the function @return [Pepito::Handler]
robot[R]
Currently running robot @return [Pepito::Robot]
Public Class Methods
new(robot, klass, func)
click to toggle source
@param robot [Pepito::Robot] The currently running robot. @param klass [Pepito::Handler] The class where to call the function. @param func [Symbol] The function to call. @return [void]
# File lib/pepito/http_api/http_callback.rb, line 23 def initialize(robot, klass, func) @robot = robot @klass = klass @func = func end
Public Instance Methods
call(env)
click to toggle source
Call method @param env [Object] The environment of the request @return [void]
# File lib/pepito/http_api/http_callback.rb, line 32 def call(env) request = Rack::Request.new(env) response = Rack::Response.new if request.head? response.status = 204 else begin @klass.public_send(@func, request, response) response.finish rescue => e puts e end end end