Class: Mxrb::Semantic::CrossModuleMovePlan
- Inherits:
-
Object
- Object
- Mxrb::Semantic::CrossModuleMovePlan
- Defined in:
- lib/mxrb/semantic/mover.rb
Overview
Cross-module move: relocates a unit AND renames its qualified name across the project so that all references stay consistent.
Instance Attribute Summary collapse
-
#before_container ⇒ Object
readonly
Returns the value of attribute before_container.
-
#rename_changes ⇒ Object
readonly
Returns the value of attribute rename_changes.
-
#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:, rename_plan:, before_container:, containment_name:) ⇒ CrossModuleMovePlan
constructor
A new instance of CrossModuleMovePlan.
Constructor Details
#initialize(project:, source:, target:, rename_plan:, before_container:, containment_name:) ⇒ CrossModuleMovePlan
Returns a new instance of CrossModuleMovePlan.
44 45 46 47 48 49 50 51 52 |
# File 'lib/mxrb/semantic/mover.rb', line 44 def initialize(project:, source:, target:, rename_plan:, before_container:, containment_name:) @project = project @source = source @target = target @rename_plan = rename_plan @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.
42 43 44 |
# File 'lib/mxrb/semantic/mover.rb', line 42 def before_container @before_container end |
#rename_changes ⇒ Object (readonly)
Returns the value of attribute rename_changes.
42 43 44 |
# File 'lib/mxrb/semantic/mover.rb', line 42 def rename_changes @rename_changes end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
42 43 44 |
# File 'lib/mxrb/semantic/mover.rb', line 42 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
42 43 44 |
# File 'lib/mxrb/semantic/mover.rb', line 42 def target @target end |
Instance Method Details
#after_container ⇒ Object
54 |
# File 'lib/mxrb/semantic/mover.rb', line 54 def after_container = target.unit_id |
#applied? ⇒ Boolean
57 |
# File 'lib/mxrb/semantic/mover.rb', line 57 def applied? = @applied |
#apply! ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mxrb/semantic/mover.rb', line 59 def apply! raise ArgumentError, "cross-module move plan was already applied" if applied? @project.mpr.transaction do @rename_plan.documents.each do |unit_id, doc| @project.mpr.update_unit(unit_id, doc) end @project.mpr.relocate_unit( @source.unit_id, container_uuid: @target.unit_id, containment_name: @containment_name ) end @project.refresh! @applied = true self end |
#empty? ⇒ Boolean
55 |
# File 'lib/mxrb/semantic/mover.rb', line 55 def empty? = false |