lib/allocation_stats/allocations_proxy.rb
# Map to bytes via {Allocation#memsize #memsize}. This is done in one of
# two ways:
#
# * If the current result set is an Array, then this transform just maps
#   each Allocation to its `#memsize`.
# * If the current result set is a Hash (meaning it has been grouped), then
#   this transform maps each value in the Hash (which is an Array of
#   Allocations) to the sum of the Allocation `#memsizes` within.
Map to bytes via {Allocation#memsize #memsize}. This is done in one of
two ways.

If the current result set is an Array, then this transform just maps
each Allocation to its `#memsize`.
If the current result set is a Hash (meaning it has been grouped), then
this transform maps each value in the Hash (which is an Array of
Allocations) to the sum of the Allocation `#memsizes` within.
Map to bytes via { Allocation#memsize #memsize } . This is done in one of two ways . If the current result set is an Array then this transform just maps each Allocation to its ` #memsize ` . If the current result set is a Hash ( meaning it has been grouped ) then this transform maps each value in the Hash ( which is an Array of Allocations ) to the sum of the Allocation ` #memsizes ` within .
def bytes
      @mappers << Proc.new do |allocations|
        if allocations.is_a? Array
          allocations.map(&:memsize)
        elsif allocations.is_a? Hash
          bytes_h = {}
          allocations.each do |key, allocations|
            bytes_h[key] = allocations.inject(0) { |sum, allocation| sum + allocation.memsize }
          end
          bytes_h
        end
      end
      self
    end
def bytes @mappers << Proc . new do | allocations | if allocations . is_a? Array allocations . map ( & :memsize ) elsif allocations . is_a? Hash bytes_h = { } allocations . each do | key , allocations | bytes_h [ key ] = allocations . inject ( 0 ) { | sum , allocation | sum + allocation . memsize } end bytes_h end end self end
Map to bytes via {Allocation#memsize #memsize}.
Map to bytes via { Allocation#memsize #memsize } .