Class: TShield::RequestVCR
- Defined in:
- lib/tshield/request_vcr.rb
Overview
Module to write and read saved responses
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ RequestVCR
constructor
A new instance of RequestVCR.
- #request ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ RequestVCR
Returns a new instance of RequestVCR.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tshield/request_vcr.rb', line 17 def initialize(path, = {}) super() @path = path @options = request_configuration = configuration.request @options[:timeout] = request_configuration['timeout'] @options[:verify] = request_configuration['verify_ssl'] request end |
Instance Method Details
#request ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tshield/request_vcr.rb', line 28 def request raw_query = @options[:raw_query] @path = "#{@path}?#{raw_query}" unless !raw_query || raw_query.empty? @url = "#{domain}#{@path}" if exists response.original = false response else configuration.get_before_filters(domain).each do |filter| _method, @url, @options = filter.new.filter(method, @url, @options) end raw = HTTParty.send(method.to_s, @url, @options) configuration.get_after_filters(domain).each do |filter| raw = filter.new.filter(raw) end original_response = save(raw) original_response.original = true original_response end end |