Class: Mxrb::Semantic::MovePlan
- Inherits:
-
Object
- Object
- Mxrb::Semantic::MovePlan
- Defined in:
- lib/mxrb/semantic/mover.rb
Instance Attribute Summary collapse
-
#before_container ⇒ Object
readonly
Returns the value of attribute before_container.
-
#containment_name ⇒ Object
readonly
Returns the value of attribute containment_name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #after_container ⇒ Object
- #applied? ⇒ Boolean
- #apply! ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(project:, source:, target:, before_container:, containment_name:) ⇒ MovePlan
constructor
A new instance of MovePlan.
Constructor Details
#initialize(project:, source:, target:, before_container:, containment_name:) ⇒ MovePlan
Returns a new instance of MovePlan.
8 9 10 11 12 13 14 15 |
# File 'lib/mxrb/semantic/mover.rb', line 8 def initialize(project:, source:, target:, before_container:, containment_name:) @project = project @source = source @target = target @before_container = before_container @containment_name = containment_name @applied = false end |
Instance Attribute Details
#before_container ⇒ Object (readonly)
Returns the value of attribute before_container.
6 7 8 |
# File 'lib/mxrb/semantic/mover.rb', line 6 def before_container @before_container end |
#containment_name ⇒ Object (readonly)
Returns the value of attribute containment_name.
6 7 8 |
# File 'lib/mxrb/semantic/mover.rb', line 6 def containment_name @containment_name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/mxrb/semantic/mover.rb', line 6 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/mxrb/semantic/mover.rb', line 6 def target @target end |
Instance Method Details
#after_container ⇒ Object
17 |
# File 'lib/mxrb/semantic/mover.rb', line 17 def after_container = target.unit_id |
#applied? ⇒ Boolean
19 |
# File 'lib/mxrb/semantic/mover.rb', line 19 def applied? = @applied |
#apply! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mxrb/semantic/mover.rb', line 21 def apply! raise ArgumentError, "move plan was already applied" if applied? unless empty? @project.mpr.transaction do @project.mpr.relocate_unit( source.unit_id, container_uuid: after_container, containment_name: ) end end @project.refresh! @applied = true self end |
#empty? ⇒ Boolean
18 |
# File 'lib/mxrb/semantic/mover.rb', line 18 def empty? = before_container == after_container |