Class: Pepito::HTTPApi::HTTPCallback
- Inherits:
-
Object
- Object
- Pepito::HTTPApi::HTTPCallback
- Defined in:
- lib/pepito/http_api/http_callback.rb
Overview
Class to help callback functions for the http routes
Instance Attribute Summary collapse
-
#func ⇒ Symbol
readonly
The function to call.
-
#klass ⇒ Pepito::Handler
readonly
The class to call the function.
-
#robot ⇒ Pepito::Robot
readonly
Currently running robot.
Instance Method Summary collapse
-
#call(env) ⇒ void
Call method.
- #initialize(robot, klass, func) ⇒ void constructor
Constructor Details
#initialize(robot, klass, func) ⇒ void
23 24 25 26 27 |
# File 'lib/pepito/http_api/http_callback.rb', line 23 def initialize(robot, klass, func) @robot = robot @klass = klass @func = func end |
Instance Attribute Details
#func ⇒ Symbol (readonly)
The function to call
17 18 19 |
# File 'lib/pepito/http_api/http_callback.rb', line 17 def func @func end |
#klass ⇒ Pepito::Handler (readonly)
The class to call the function
13 14 15 |
# File 'lib/pepito/http_api/http_callback.rb', line 13 def klass @klass end |
#robot ⇒ Pepito::Robot (readonly)
Currently running robot
9 10 11 |
# File 'lib/pepito/http_api/http_callback.rb', line 9 def robot @robot end |
Instance Method Details
#call(env) ⇒ void
This method returns an undefined value.
Call method
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 |