Class: TShield::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/tshield/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Request

Returns a new instance of Request.



18
19
20
21
22
23
24
# File 'lib/tshield/request.rb', line 18

def initialize(path, options = {})
  @path = path
  @options = options 
  @configuration = TShield::Configuration.singleton
  @options[:timeout] =  @configuration.request['timeout']
  request
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



16
17
18
# File 'lib/tshield/request.rb', line 16

def response
  @response
end

Instance Method Details

#requestObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tshield/request.rb', line 26

def request
  if not (@options[:raw_query].nil? or @options[:raw_query].empty?)
    @path = "#{@path}?#{@options[:raw_query]}"
  end

  @url = "#{domain}#{@path}"

  if exists
    @response = get_current_response  
    @response.original = false
  else
    raw = HTTParty.send("#{method}", @url, @options)
    @response = save(raw)
    @response.original = true
  end
  current_session[:counter].add(@path, method) if current_session
  debugger if TShield::Options.instance.break?(path: @path, moment: :after)
  @response
end