Class: Rapuncel::Client
- Inherits:
-
Object
- Object
- Rapuncel::Client
- Includes:
- Adapters::NetHttpAdapter
- Defined in:
- lib/rapuncel/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#raise_on_error ⇒ Object
Returns the value of attribute raise_on_error.
-
#raise_on_fault ⇒ Object
Returns the value of attribute raise_on_fault.
Instance Method Summary collapse
-
#call(name, *args) ⇒ Object
Dispatch a method call and return the response as Rapuncel::Response object.
-
#call_to_ruby(name, *args) ⇒ Object
Dispatch a method call and return the response as parsed ruby.
-
#initialize(configuration = {}) ⇒ Client
constructor
A new instance of Client.
- #proxy ⇒ Object
- #proxy_for(interface) ⇒ Object
Methods included from Adapters::NetHttpAdapter
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
#connection ⇒ Object
Returns the value of attribute connection.
10 11 12 |
# File 'lib/rapuncel/client.rb', line 10 def connection @connection end |
#raise_on_error ⇒ Object
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_fault ⇒ Object
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 |
#proxy ⇒ Object
18 19 20 |
# File 'lib/rapuncel/client.rb', line 18 def proxy proxy_for nil end |