Class: AsyncConnectionAdapter

Inherits:
HTTParty::ConnectionAdapter
  • Object
show all
Defined in:
lib/resthome/httparty/async_connection_adapter.rb,
lib/resthome/httparty/async_connection_adapter.rb

Defined Under Namespace

Classes: AsyncHTTPConnection, AsyncHTTPResponse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, options) ⇒ AsyncConnectionAdapter

Returns a new instance of AsyncConnectionAdapter.



37
38
39
40
# File 'lib/resthome/httparty/async_connection_adapter.rb', line 37

def initialize(uri, options)
  @uri = uri
  @options = options
end

Class Method Details

.call(uri, options) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/resthome/httparty/async_connection_adapter.rb', line 49

def self.call(uri, options)
  if EM.reactor_running?
    self.new(uri, options).connection
  else
    HTTParty::ConnectionAdapter.call uri, options
  end
end

Instance Method Details

#connectionObject



42
43
44
45
46
47
# File 'lib/resthome/httparty/async_connection_adapter.rb', line 42

def connection
  AsyncHTTPConnection.new.tap do |c|
    c.connopts = HttpConnectionOptions.new(@uri, @options)
    c.uri = @uri
  end
end