Module: Lunetas::Candy::ResponseHandler::InstanceMethods
- Defined in:
- lib/lunetas/candy/response_handler.rb
Instance Method Summary collapse
-
#bite ⇒ Array
Bites the Candy (a.k.a process this resource).
-
#handle_call ⇒ Array
Handles the rack call.
-
#url_param(index) ⇒ String
Returns the url parameter from the regular expresion.
Instance Method Details
#bite ⇒ Array
Bites the Candy (a.k.a process this resource).
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lunetas/candy/response_handler.rb', line 27 def bite raise @_error if @_error before response(handle_call) rescue Exception => e code, error = 500, e if Lunetas::Error::BaseError === e code = e.code elsif development? error = "Error: #{e.}\nBacktrace: #{e.backtrace.join("\n")}" end response(error, code) end |
#handle_call ⇒ Array
Handles the rack call. Delegates it to the method that matches the request method.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lunetas/candy/response_handler.rb', line 8 def handle_call case @req.request_method when 'GET' then get when 'POST' then post when 'PUT' then put when 'DELETE' then delete when 'HEAD' then head when 'TRACE' then trace when 'OPTIONS' then else response = other_verb(@req.request_method) raise Lunetas::Error::APIError unless response response end end |
#url_param(index) ⇒ String
Returns the url parameter from the regular expresion. If a captured block is given, then they will be added in order of appearance.
45 46 47 |
# File 'lib/lunetas/candy/response_handler.rb', line 45 def url_param(index) @lunetas_url_instance_params[index] end |