Class: Rabal::ActionTree

Inherits:
Tree
  • Object
show all
Defined in:
lib/rabal/action_tree.rb

Direct Known Subclasses

DirectoryTree, FileTree

Instance Attribute Summary

Attributes inherited from Tree

#children, #name, #parameters, #parent

Instance Method Summary collapse

Methods inherited from Tree

#<<, #add_at_path, #current_path, #depth, #each, #find_subtree, #has_subtree?, #is_leaf?, #is_root?, #method_missing, #post_add, #root, #size, #tree_at_path, #walk

Constructor Details

#initialize(data) ⇒ ActionTree

Returns a new instance of ActionTree.



6
7
8
# File 'lib/rabal/action_tree.rb', line 6

def initialize(data)
    super(data)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rabal::Tree

Instance Method Details

#actionObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/rabal/action_tree.rb', line 13

def action
    raise NotImplementedError, "Oops, forgot to implement 'action'"
end

#after_actionObject



17
18
# File 'lib/rabal/action_tree.rb', line 17

def after_action 
end

#before_actionObject



10
11
# File 'lib/rabal/action_tree.rb', line 10

def before_action
end

#processObject

Walk the tree recursively processing each subtree. The process is:

  • execute before_action

  • execute action

  • process each child

  • execute after_action



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rabal/action_tree.rb', line 30

def process
    before_action

    action

    children.each_pair do |name,child|
        child.process
    end

    after_action
end