Class: Rapuncel::Client

Inherits:
Object
  • Object
show all
Includes:
Adapters::NetHttpAdapter
Defined in:
lib/rapuncel/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Adapters::NetHttpAdapter

#send_method_call

Constructor Details

#initialize(configuration = {}) ⇒ Client

Returns a new instance of Client.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rapuncel/client.rb', line 22

def initialize configuration = {}
  @connection = Connection.new configuration.except(:raise_on, :serialization)
  @serialization = configuration[:serialization]
  
  @raise_on_fault, @raise_on_error = case configuration[:raise_on]
  when :fault
    [true, false]
  when :error
    [false, true]
  when :both
    [true, true]
  else
    [false, false]
  end
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



10
11
12
# File 'lib/rapuncel/client.rb', line 10

def connection
  @connection
end

#raise_on_errorObject

Returns the value of attribute raise_on_error.



10
11
12
# File 'lib/rapuncel/client.rb', line 10

def raise_on_error
  @raise_on_error
end

#raise_on_faultObject

Returns the value of attribute raise_on_fault.



10
11
12
# File 'lib/rapuncel/client.rb', line 10

def raise_on_fault
  @raise_on_fault
end

Instance Method Details

#call(name, *args) ⇒ Object

Dispatch a method call and return the response as Rapuncel::Response object.



39
40
41
# File 'lib/rapuncel/client.rb', line 39

def call name, *args
  execute Request.new(name, *args)
end

#call_to_ruby(name, *args) ⇒ Object

Dispatch a method call and return the response as parsed ruby.



44
45
46
47
48
49
50
51
# File 'lib/rapuncel/client.rb', line 44

def call_to_ruby name, *args
  response = call name, *args

  raise_on_fault && response.fault? && raise_fault(response)
  raise_on_error && response.error? && raise_error(response)

  response.to_ruby
end

#proxyObject



18
19
20
# File 'lib/rapuncel/client.rb', line 18

def proxy
  proxy_for nil
end

#proxy_for(interface) ⇒ Object



14
15
16
# File 'lib/rapuncel/client.rb', line 14

def proxy_for interface
  Proxy.new self, interface
end