Class: Guide::Monkey
- Inherits:
-
Object
- Object
- Guide::Monkey
- Defined in:
- app/models/guide/monkey.rb
Instance Method Summary collapse
- #fetch_node(node_path) ⇒ Object
-
#initialize(starting_node, bouncer) ⇒ Monkey
constructor
A new instance of Monkey.
Constructor Details
#initialize(starting_node, bouncer) ⇒ Monkey
Returns a new instance of Monkey.
2 3 4 5 6 7 8 |
# File 'app/models/guide/monkey.rb', line 2 def initialize(starting_node, bouncer) @starting_node = starting_node @bouncer = bouncer ensure_starting_node_exists ensure_user_can_access(@starting_node) end |
Instance Method Details
#fetch_node(node_path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/guide/monkey.rb', line 10 def fetch_node(node_path) current_node = @starting_node node_ids_along_path(node_path).each do |node_id| current_node = current_node.child_nodes[node_id] ensure_node_exists(current_node, node_id) ensure_user_can_access(current_node) end current_node end |