Class: HungSecondGem::Hola

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hung_secondGem/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Hola

Returns a new instance of Hola.



17
18
# File 'lib/hung_secondGem/version.rb', line 17

def initialize()
end

Instance Attribute Details

#last_resObject

Returns the value of attribute last_res.



13
14
15
# File 'lib/hung_secondGem/version.rb', line 13

def last_res
  @last_res
end

#responseObject (readonly)

Returns the value of attribute response.



14
15
16
# File 'lib/hung_secondGem/version.rb', line 14

def response
  @response
end

#resquestObject (readonly)

Returns the value of attribute resquest.



15
16
17
# File 'lib/hung_secondGem/version.rb', line 15

def resquest
  @resquest
end

Instance Method Details

#helloObject



65
66
67
# File 'lib/hung_secondGem/version.rb', line 65

def hello
  puts "Hello Hung"
end

#mergeOpt(opts = {}) ⇒ Object



24
25
26
27
# File 'lib/hung_secondGem/version.rb', line 24

def mergeOpt(opts={})
  self.class.default_options.merge(opts)
  puts self.class.default_options
end

#perform_request(http_method, path, options = {}, &block) ⇒ Object

:nodoc:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hung_secondGem/version.rb', line 34

def perform_request(http_method, path, options={}, &block)  #:nodoc:
  method = eval("Net::HTTP::#{http_method.to_s.capitalize}")
  options = ModuleInheritableAttributes.hash_deep_dup(self.class.default_options).merge(options)

  process_headers(options)
  process_cookies(options)
  puts options
  begin
    @response = HTTParty::Request.new(method, path, options).perform(&block)

    setDebug
  rescue => e
    puts "Rescued #{e.inspect}"
    setDebug
  end

  @response
end

#process_cookies(options) ⇒ Object

:nodoc:



59
60
61
62
63
# File 'lib/hung_secondGem/version.rb', line 59

def process_cookies(options) #:nodoc:
  return unless options[:cookies] || self.class.default_cookies.any?
  options[:headers] ||= headers.dup
  options[:headers]['cookie'] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
end

#process_headers(options) ⇒ Object



53
54
55
56
57
# File 'lib/hung_secondGem/version.rb', line 53

def process_headers(options)
  if options[:headers] && headers.any?
    options[:headers] = headers.merge(options[:headers])
  end
end

#setDebugObject



29
30
31
32
# File 'lib/hung_secondGem/version.rb', line 29

def setDebug
  self.class.debug_output $stdout
  self.class.debug_output $stderr
end