Class: Hessian2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hessian2/client.rb

Direct Known Subclasses

HessianClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hessian2/client.rb', line 9

def initialize(url, options = {})
  uri = URI.parse(url)
  @scheme, @host, @port, @path = uri.scheme, uri.host, uri.port, uri.path.empty? ? '/' : uri.path
  @path += "?#{uri.query}" if uri.query
  raise "Unsupported Hessian protocol: #{@scheme}" unless %w(http https).include?(@scheme)
  @async = options.delete(:async)
  @fiber_aware = options.delete(:fiber_aware)
  if @async || @fiber_aware
    begin
      require 'em-synchrony/em-http'
    rescue LoadError => error
      raise "Missing EM-Synchrony dependency: gem install em-synchrony em-http-request"
    end
  else
    require 'net/http'
  end
  @proxy = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object



29
30
31
# File 'lib/hessian2/client.rb', line 29

def method_missing(id, *args)
  return invoke(id.id2name, args)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/hessian2/client.rb', line 7

def host
  @host
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/hessian2/client.rb', line 6

def password
  @password
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/hessian2/client.rb', line 7

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/hessian2/client.rb', line 7

def port
  @port
end

#proxyObject (readonly)

Returns the value of attribute proxy.



7
8
9
# File 'lib/hessian2/client.rb', line 7

def proxy
  @proxy
end

#schemeObject (readonly)

Returns the value of attribute scheme.



7
8
9
# File 'lib/hessian2/client.rb', line 7

def scheme
  @scheme
end

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/hessian2/client.rb', line 6

def user
  @user
end