Class: Rabal::ActionTree
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Tree
#children, #name, #parameters, #parent
Instance Method Summary collapse
- #action ⇒ Object
- #after_action ⇒ Object
- #before_action ⇒ Object
-
#initialize(data) ⇒ ActionTree
constructor
A new instance of ActionTree.
-
#process ⇒ Object
Walk the tree recursively processing each subtree.
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
#action ⇒ Object
13 14 15 |
# File 'lib/rabal/action_tree.rb', line 13 def action raise NotImplementedError, "Oops, forgot to implement 'action'" end |
#after_action ⇒ Object
17 18 |
# File 'lib/rabal/action_tree.rb', line 17 def after_action end |
#before_action ⇒ Object
10 11 |
# File 'lib/rabal/action_tree.rb', line 10 def before_action end |
#process ⇒ Object
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 |