Module: Mongoid::Acts::NestedSet::Update
- Included in:
- Document::InstanceMethods
- Defined in:
- lib/mongoid_nested_set/update.rb
Instance Method Summary collapse
-
#move_left ⇒ Object
Shorthand method for finding the left sibling and moving to the left of it.
- #move_possible?(target) ⇒ Boolean
-
#move_right ⇒ Object
Shorthand method for finding the right sibling and moving to the right of it.
-
#move_to_child_of(node) ⇒ Object
Move the node to the child of another node (you can pass id only).
-
#move_to_left_of(node) ⇒ Object
Move the node to the left of another node (you can pass id only).
-
#move_to_right_of(node) ⇒ Object
Move the node to the right of another node (you can pass id only).
-
#move_to_root ⇒ Object
Move the node to root nodes.
Instance Method Details
#move_left ⇒ Object
Shorthand method for finding the left sibling and moving to the left of it
6 7 8 |
# File 'lib/mongoid_nested_set/update.rb', line 6 def move_left move_to_left_of left_sibling end |
#move_possible?(target) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/mongoid_nested_set/update.rb', line 41 def move_possible?(target) self != target && # Can't target self same_scope?(target) && # can't be in different scopes !((left <= target.left && right >= target.left) or (left <= target.right && right >= target.right)) end |
#move_right ⇒ Object
Shorthand method for finding the right sibling and moving to the right of it
12 13 14 |
# File 'lib/mongoid_nested_set/update.rb', line 12 def move_right move_to_right_of right_sibling end |
#move_to_child_of(node) ⇒ Object
Move the node to the child of another node (you can pass id only)
30 31 32 |
# File 'lib/mongoid_nested_set/update.rb', line 30 def move_to_child_of(node) move_to node, :child end |
#move_to_left_of(node) ⇒ Object
Move the node to the left of another node (you can pass id only)
18 19 20 |
# File 'lib/mongoid_nested_set/update.rb', line 18 def move_to_left_of(node) move_to node, :left end |
#move_to_right_of(node) ⇒ Object
Move the node to the right of another node (you can pass id only)
24 25 26 |
# File 'lib/mongoid_nested_set/update.rb', line 24 def move_to_right_of(node) move_to node, :right end |
#move_to_root ⇒ Object
Move the node to root nodes
36 37 38 |
# File 'lib/mongoid_nested_set/update.rb', line 36 def move_to_root move_to nil, :root end |