module PipeRpc class Mapper def map(object, &mapper) if Client === object # first filter out clients so for them subsequent checks are not sent # through the pipe yield object elsif Hash === object object.map{ |k, v| [k, map(v, &mapper)] }.to_h elsif object.respond_to? :map object.map{ |item| map(item, &mapper) } else yield object end end end end