Class: SimpleNestedSet::Move::ByAttributes
- Inherits:
-
Object
- Object
- SimpleNestedSet::Move::ByAttributes
- Includes:
- Protection
- Defined in:
- lib/simple_nested_set/move/by_attributes.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node, attributes) ⇒ ByAttributes
constructor
A new instance of ByAttributes.
- #perform ⇒ Object
Methods included from Protection
#impossible_move!, #inconsistent_move!, #protect_impossible_move!, #protect_inconsistent_move!
Constructor Details
#initialize(node, attributes) ⇒ ByAttributes
Returns a new instance of ByAttributes.
10 11 12 13 14 |
# File 'lib/simple_nested_set/move/by_attributes.rb', line 10 def initialize(node, attributes) @node, @attributes = node, attributes normalize_attributes! protect_inconsistent_move! end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/simple_nested_set/move/by_attributes.rb', line 6 def attributes @attributes end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/simple_nested_set/move/by_attributes.rb', line 6 def node @node end |
Instance Method Details
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/simple_nested_set/move/by_attributes.rb', line 16 def perform move_by_parent_id if move_by_parent_id? if path && node.path_changed? node.move_to_path(path) elsif move_by_left_id? move_by_left_id elsif move_by_right_id? move_by_right_id end end |