Class: Lymbix::Request
- Inherits:
-
Object
- Object
- Lymbix::Request
- Defined in:
- lib/lymbix/request.rb
Instance Attribute Summary collapse
-
#header_hash ⇒ Object
Returns the value of attribute header_hash.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#method ⇒ Object
Returns the value of attribute method.
-
#object ⇒ Object
Returns the value of attribute object.
-
#response ⇒ Object
Returns the value of attribute response.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(http_method, method, header_hash, object = nil) ⇒ Request
constructor
:nodoc:.
- #run ⇒ Object
Constructor Details
#initialize(http_method, method, header_hash, object = nil) ⇒ Request
:nodoc:
8 9 10 11 12 13 14 |
# File 'lib/lymbix/request.rb', line 8 def initialize(http_method, method, header_hash, object = nil) #:nodoc: self.http_method = http_method self.url = Lymbix::Configuration.host self.method = method self.object = object self.header_hash = header_hash end |
Instance Attribute Details
#header_hash ⇒ Object
Returns the value of attribute header_hash.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def header_hash @header_hash end |
#http_method ⇒ Object
Returns the value of attribute http_method.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def http_method @http_method end |
#method ⇒ Object
Returns the value of attribute method.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def method @method end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def object @object end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def response @response end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/lymbix/request.rb', line 6 def url @url end |
Instance Method Details
#connection ⇒ Object
16 17 18 19 20 |
# File 'lib/lymbix/request.rb', line 16 def connection = {} [:headers] = {:accept => self.header_hash[:accept_type], :AUTHENTICATION => self.header_hash[:auth_key], :VERSION => self.header_hash[:version]} RestClient::Resource.new(self.url, ) end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lymbix/request.rb', line 22 def run case(self.http_method) when :get self.connection[self.method].get do |resp| self.response = resp.body end when :post self.connection[self.method].post(object) do |resp| self.response = resp.body end end Response.new(self.response) end |