Class: DTC::Utils::Visitor::FilteringForwarder

Inherits:
Forwarder
  • Object
show all
Defined in:
lib/dtc/utils/visitor.rb

Overview

Base class for forwarding visitors that forward events only for items on which a call to ‘include?(is_leaf, *args)` returns true.

You can include, but not descend, a node by overriding ‘descend?(*args)` too.

Instance Attribute Summary

Attributes inherited from Forwarder

#next_visitor

Instance Method Summary collapse

Methods inherited from Forwarder

#initialize, #leave

Constructor Details

This class inherits a constructor from DTC::Utils::Visitor::Forwarder

Instance Method Details

#add(*args) ⇒ Object



252
253
254
255
# File 'lib/dtc/utils/visitor.rb', line 252

def add *args
  return false unless include?(true, *args)
  super
end

#enter(*args) ⇒ Object



244
245
246
247
248
249
250
251
# File 'lib/dtc/utils/visitor.rb', line 244

def enter *args
  return false unless include?(false, *args)
  if (result = super) && !descend?(*args)
    leave
    return false
  end
  result
end