Sha256: 039dec5f1df25e50f22c78fc12a03884e9537095792ccbc9271bfb661db916fc
Contents?: true
Size: 713 Bytes
Versions: 5
Compression:
Stored size: 713 Bytes
Contents
# frozen_string_literal: true module CallableTree module Node attr_reader :parent def ancestors ::Enumerator.new do |y| node = self loop do y << node break unless node = node&.parent end end end def routes ancestors.map(&:identity) end def identity self.class end def depth parent.nil? ? 0 : parent.depth + 1 end def match?(_input = nil, **_options) true end def call(_input = nil, **_options) raise ::CallableTree::Error, 'Not implemented' end def terminate?(output = nil, **_options) !output.nil? end private attr_writer :parent end end
Version data entries
5 entries across 5 versions & 1 rubygems