Sha256: 98edb5d29ad8baf363090625f3544324734405ad311512e8daea61d27b706f19
Contents?: true
Size: 515 Bytes
Versions: 18
Compression:
Stored size: 515 Bytes
Contents
module Elastic::Support module Traversable def traverse(&_block) raise NotImplementedError, "every traversable tree must implement 'traverse'" end def pick(*_types, &_block) if _types.empty? enum = Enumerator.new do |y| traverse { |h| y << h } end else enum = Enumerator.new do |y| traverse { |h| y << h if _types.any? { |t| h.is_a? t } } end end return enum if _block.nil? enum.each(&_block) end end end
Version data entries
18 entries across 18 versions & 1 rubygems