class AndSon::TestClient
Constants
- Call
Attributes
after_call_procs[R]
before_call_procs[R]
calls[R]
logger_value[RW]
params_value[RW]
responses[R]
timeout_value[RW]
Public Class Methods
new(host, port)
click to toggle source
Calls superclass method
AndSon::Client::new
# File lib/and-son/client.rb, line 63 def initialize(host, port) super @calls = [] @responses = AndSon::StoredResponses.new @params_value = {} @before_call_procs = [] @after_call_procs = [] end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/and-son/client.rb, line 117 def ==(other) other.kind_of?(self.class) ? self.hash == other.hash : super end
Also aliased as: eql?
add_response(name, &block)
click to toggle source
# File lib/and-son/client.rb, line 95 def add_response(name, &block) self.responses.add(name, &block) end
call(name, params = nil) { |protocol_response| ... }
click to toggle source
# File lib/and-son/client.rb, line 73 def call(name, params = nil) params ||= {} callback_params = self.params_value.merge(params) # attempt to encode (and then throw away) the request, this will error on # the developer if it can't encode the request request = Sanford::Protocol::Request.new(name, params) Sanford::Protocol.msg_body.encode(request.to_hash) response = self.responses.get(name, params) self.before_call_procs.each{ |p| p.call(name, callback_params, self) } self.calls << Call.new(name, params, response.protocol_response) self.after_call_procs.each{ |p| p.call(name, callback_params, self) } if block_given? yield response.protocol_response else response.data end end
call_runner()
click to toggle source
# File lib/and-son/client.rb, line 93 def call_runner; self; end
hash()
click to toggle source
# File lib/and-son/client.rb, line 108 def hash [ self.host, self.port, self.timeout_value, self.params_value, self.logger_value ].hash end
remove_responses(name)
click to toggle source
# File lib/and-son/client.rb, line 99 def remove_responses(name) self.responses.remove(name) end
reset()
click to toggle source
# File lib/and-son/client.rb, line 103 def reset self.calls.clear self.responses.remove_all end