module AndSon::CallRunner::InstanceMethods

Public Instance Methods

after_call(&block) click to toggle source
# File lib/and-son/call_runner.rb, line 114
def after_call(&block)
  self.call_runner.tap{ |r| r.after_call_procs << block }
end
before_call(&block) click to toggle source
# File lib/and-son/call_runner.rb, line 110
def before_call(&block)
  self.call_runner.tap{ |r| r.before_call_procs << block }
end
logger(passed_logger) click to toggle source
# File lib/and-son/call_runner.rb, line 106
def logger(passed_logger)
  self.call_runner.tap{ |r| r.logger_value = passed_logger }
end
params(hash = nil) click to toggle source
# File lib/and-son/call_runner.rb, line 99
def params(hash = nil)
  if !hash.kind_of?(Hash)
    raise ArgumentError, "expected params to be a Hash instead of a #{hash.class}"
  end
  self.call_runner.tap{ |r| r.params_value.merge!(stringify_keys(hash)) }
end
timeout(seconds) click to toggle source

define methods here to allow configuring call runner params. be sure to use `tap` to return whatever instance `self.call_runner` returns so you can method-chain. `self.call_runner` returns a new runner instance if called on a client, but returns the chained instance if called on a runner

# File lib/and-son/call_runner.rb, line 95
def timeout(seconds)
  self.call_runner.tap{ |r| r.timeout_value = seconds.to_f }
end

Private Instance Methods

stringify_keys(hash) click to toggle source
# File lib/and-son/call_runner.rb, line 120
def stringify_keys(hash)
  hash.inject({}){|h, (k, v)| h.merge({ k.to_s => v }) }
end