Class: DTC::Utils::Visitor::DSL::RecursiveDSLDelegate
- Inherits:
-
Object
- Object
- DTC::Utils::Visitor::DSL::RecursiveDSLDelegate
- Defined in:
- lib/dtc/utils/visitor/dsl.rb
Overview
Utility class to keep track of the running prefix as the DSL is visited
Instance Method Summary collapse
- #add(sym, *args) ⇒ Object
- #enter(sym, *args) ⇒ Object
- #flush ⇒ Object
-
#initialize(visitor, prefix = nil) ⇒ RecursiveDSLDelegate
constructor
A new instance of RecursiveDSLDelegate.
- #leave ⇒ Object
- #prefix(sym) ⇒ Object
Constructor Details
#initialize(visitor, prefix = nil) ⇒ RecursiveDSLDelegate
Returns a new instance of RecursiveDSLDelegate.
19 20 21 22 23 24 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 19 def initialize visitor, prefix = nil @visitor = visitor @prefix = prefix @pending_prefix = nil @called = false end |
Instance Method Details
#add(sym, *args) ⇒ Object
36 37 38 39 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 36 def add sym, *args @called = true @visitor.add(with_prefix(sym), *args) end |
#enter(sym, *args) ⇒ Object
40 41 42 43 44 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 40 def enter sym, *args flush @called = true @visitor.enter(with_prefix(sym), *args) end |
#flush ⇒ Object
30 31 32 33 34 35 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 30 def flush if @pending_prefix @pending_prefix.add_unless_called @pending_prefix = nil end end |
#leave ⇒ Object
45 46 47 48 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 45 def leave flush @visitor.leave end |
#prefix(sym) ⇒ Object
25 26 27 28 29 |
# File 'lib/dtc/utils/visitor/dsl.rb', line 25 def prefix sym @called = true flush @pending_prefix = self.class.new(@visitor, with_prefix(sym)) end |