Class: Amiando::Request
- Inherits:
-
Typhoeus::Request
- Object
- Typhoeus::Request
- Amiando::Request
- Defined in:
- lib/amiando/request.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #filter_log(text) ⇒ Object
-
#initialize(object, verb, path, params, options = {}) ⇒ Request
constructor
A new instance of Request.
- #log_request ⇒ Object
- #log_response ⇒ Object
Constructor Details
#initialize(object, verb, path, params, options = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/amiando/request.rb', line 5 def initialize(object, verb, path, params, = {}) @object = object if verb == :post path = build_url(path, default_params) else path = build_url(path) params = default_params.merge(params || {}) end = .merge(:method => verb, :params => params, :verbose => Amiando.verbose, :timeout => Amiando.timeout) super(path, ) end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/amiando/request.rb', line 3 def object @object end |
Instance Method Details
#filter_log(text) ⇒ Object
34 35 36 |
# File 'lib/amiando/request.rb', line 34 def filter_log(text) text.gsub(/password=([^&]+)/, "password=[FILTERED]").gsub(/password: .*/,'password: [FILTERED]') end |
#log_request ⇒ Object
19 20 21 22 23 |
# File 'lib/amiando/request.rb', line 19 def log_request if Amiando.logger && Amiando.logger.debug? Amiando.logger.debug "#{self.method.to_s.upcase} request #{filter_log(url)} with body #{filter_log(self.params.inspect)}" end end |
#log_response ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/amiando/request.rb', line 25 def log_response if Amiando.logger Amiando.logger.info "#{self.method.to_s.upcase} request #{filter_log(url)} returned #{response.code} and took #{response.time} seconds" if Amiando.logger.debug? && response.body Amiando.logger.debug "#{self.method.to_s.upcase} response body: #{filter_log(response.body.inspect)}" end end end |