Sha256: 6983d329b2418c137dc493c78736a09145eae4085898bcd7343e31cb1f5d572f

Contents?: true

Size: 438 Bytes

Versions: 2

Compression:

Stored size: 438 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipe_rpc-2.5.0 lib/pipe_rpc/mapper.rb
pipe_rpc-2.4.0 lib/pipe_rpc/mapper.rb