Can you replace the line
raise ArgumentError, "wrong number of arguments (#{args.length} for 2)"
with
opts = args.pop if args.last.is_a?( Hash )
servers = args
in the case else portion of the initialize function so that memcache-client will support MemCache.new(*addresses) parameter
notations as Ruby-memcache?
Thanks,
Tron
Original code listed below:
def initialize(*args)
servers = []
opts = {}
case args.length
when 0 then # NOP
when 1 then
arg = args.shift
case arg
when Hash then opts = arg
when Array then servers = arg
when String then servers = [arg]
else raise ArgumentError, 'first argument must be Array, Hash or String'
end
when 2 then
servers, opts = args
else
raise ArgumentError, "wrong number of arguments (#{args.length} for 2)"
end
opts = DEFAULT_OPTIONS.merge opts
@namespace = opts[:namespace]
@readonly = opts[:readonly]
@multithread = opts[:multithread]
@mutex = Mutex.new if @multithread
@buckets = []
self.servers = servers
end
|