Class: ApiModel::HttpRequest

Inherits:
Object
  • Object
show all
Includes:
Initializer
Defined in:
lib/api_model/http_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Initializer

#initialize

Methods included from Assignment

#update_attributes

Instance Attribute Details

#api_callObject

Returns the value of attribute api_call.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def api_call
  @api_call
end

#builderObject

Returns the value of attribute builder.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def builder
  @builder
end

#cache_idObject

Returns the value of attribute cache_id.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def cache_id
  @cache_id
end

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def config
  @config
end

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def method
  @method
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def options
  @options
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/api_model/http_request.rb', line 5

def path
  @path
end

Instance Method Details

#full_pathObject



40
41
42
43
# File 'lib/api_model/http_request.rb', line 40

def full_path
  return path if path =~ /^http/
  "#{config.host}#{path}"
end

#request_methodObject



45
46
47
# File 'lib/api_model/http_request.rb', line 45

def request_method
  api_call.request.original_options[:method]
end

#runObject



24
25
26
27
28
29
30
# File 'lib/api_model/http_request.rb', line 24

def run
  run_callbacks :run_request do
    Log.debug "#{method.to_s.upcase} #{full_path} with headers: #{options[:headers]}"
    self.api_call = Typhoeus.send method, full_path, options
    Response.new self, config
  end
end