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).
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lunetas/candy/response_handler.rb', line 34 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 23 24 25 26 27 28 29 |
# File 'lib/lunetas/candy/response_handler.rb', line 8 def handle_call case @req.request_method when 'GET' get when 'POST' post when 'PUT' put when 'DELETE' delete when 'HEAD' head when 'TRACE' trace when 'OPTIONS' 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.
52 53 54 |
# File 'lib/lunetas/candy/response_handler.rb', line 52 def url_param(index) @lunetas_url_instance_params[index] end |