Module: ActiveVlc::PipelineDump
- Extended by:
- ActiveSupport::Concern
- Included in:
- Pipeline, Stage::Base, Stage::Input
- Defined in:
- lib/activevlc/pipeline_dump.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- TAB_WIDTH =
2
Instance Method Summary collapse
- #_dump(depth = 0) ⇒ Object
- #_dump_depth(depth) ⇒ Object
-
#_find_in_ancestors(sym) ⇒ Object
FIXME Find an elegant way to do this :-/ Here we walk the ancestor array to find the one which included us first and therefore has a default _dump_name and _dump_childs.
Instance Method Details
#_dump(depth = 0) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/activevlc/pipeline_dump.rb', line 18 def _dump(depth = 0) name = instance_eval &_find_in_ancestors(:_dump_name) childs = instance_eval &_find_in_ancestors(:_dump_childs) "#{_dump_depth(depth)}+ #{name}\n" + childs.map { |c| c._dump(depth + 1) }.join end |
#_dump_depth(depth) ⇒ Object
26 27 28 |
# File 'lib/activevlc/pipeline_dump.rb', line 26 def _dump_depth(depth) ' ' * depth * TAB_WIDTH end |
#_find_in_ancestors(sym) ⇒ Object
FIXME Find an elegant way to do this :-/ Here we walk the ancestor array to find the one which included us first and therefore has a default _dump_name and _dump_childs. It will stops to the first ancestor which has (re)defined it.
34 35 36 37 38 39 40 |
# File 'lib/activevlc/pipeline_dump.rb', line 34 def _find_in_ancestors(sym) klass = self.class while klass.respond_to?(sym) and klass.superclass and not klass.send(sym) klass = klass.superclass end klass.send(sym) end |