Class: CollectiveIdea::Acts::NestedSet::Move
- Inherits:
-
Object
- Object
- CollectiveIdea::Acts::NestedSet::Move
- Includes:
- LegacyWhereStatementExt
- Defined in:
- lib/awesome_nested_set/move.rb
Defined Under Namespace
Modules: LegacyWhereStatementExt Classes: ImpossibleMove
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(target, position, instance) ⇒ Move
constructor
A new instance of Move.
- #move ⇒ Object
Constructor Details
#initialize(target, position, instance) ⇒ Move
Returns a new instance of Move.
7 8 9 10 11 |
# File 'lib/awesome_nested_set/move.rb', line 7 def initialize(target, position, instance) @target = target @position = position @instance = instance end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
5 6 7 |
# File 'lib/awesome_nested_set/move.rb', line 5 def instance @instance end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
5 6 7 |
# File 'lib/awesome_nested_set/move.rb', line 5 def position @position end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/awesome_nested_set/move.rb', line 5 def target @target end |
Instance Method Details
#move ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/awesome_nested_set/move.rb', line 13 def move prevent_impossible_move bound, other_bound = get_boundaries # there would be no change return if bound == right || bound == left # we have defined the boundaries of two non-overlapping intervals, # so sorting puts both the intervals and their boundaries in order a, b, c, d = [left, right, bound, other_bound].sort lock_nodes_between! a, d nested_set_scope_without_default_scope.where(where_statement(a, d)).update_all( conditions(a, b, c, d) ) end |