module Elastic::Support::Traversable
Public Instance Methods
pick(*_types, &_block)
click to toggle source
# File lib/elastic/support/traversable.rb, line 7 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
traverse(&_block)
click to toggle source
# File lib/elastic/support/traversable.rb, line 3 def traverse(&_block) raise NotImplementedError, "every traversable tree must implement 'traverse'" end