Class: Mxrb::Semantic::RenamePlan
- Inherits:
-
Object
- Object
- Mxrb::Semantic::RenamePlan
- Defined in:
- lib/mxrb/semantic/renamer.rb
Overview
Immutable preview plus the prepared BSON documents needed for an explicit apply. Construct plans through Project#plan_rename.
Instance Attribute Summary collapse
-
#architecture ⇒ Object
readonly
Returns the value of attribute architecture.
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #affected_units ⇒ Object
- #applied? ⇒ Boolean
- #apply! ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(project:, source:, target:, changes:, documents:, architecture: nil) ⇒ RenamePlan
constructor
A new instance of RenamePlan.
Constructor Details
#initialize(project:, source:, target:, changes:, documents:, architecture: nil) ⇒ RenamePlan
Returns a new instance of RenamePlan.
12 13 14 15 16 17 18 19 20 |
# File 'lib/mxrb/semantic/renamer.rb', line 12 def initialize(project:, source:, target:, changes:, documents:, architecture: nil) @project = project @source = source @target = target @changes = changes.freeze @documents = documents.freeze @architecture = architecture @applied = false end |
Instance Attribute Details
#architecture ⇒ Object (readonly)
Returns the value of attribute architecture.
10 11 12 |
# File 'lib/mxrb/semantic/renamer.rb', line 10 def architecture @architecture end |
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
10 11 12 |
# File 'lib/mxrb/semantic/renamer.rb', line 10 def changes @changes end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
10 11 12 |
# File 'lib/mxrb/semantic/renamer.rb', line 10 def documents @documents end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/mxrb/semantic/renamer.rb', line 10 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/mxrb/semantic/renamer.rb', line 10 def target @target end |
Instance Method Details
#affected_units ⇒ Object
24 |
# File 'lib/mxrb/semantic/renamer.rb', line 24 def affected_units = @documents.keys.freeze |
#applied? ⇒ Boolean
23 |
# File 'lib/mxrb/semantic/renamer.rb', line 23 def applied? = @applied |
#apply! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mxrb/semantic/renamer.rb', line 26 def apply! raise ArgumentError, "rename plan was already applied" if @applied @project.mpr.transaction do @documents.each { |unit_id, document| @project.mpr.update_unit(unit_id, document) } @project.mpr.write_architecture_definition(@architecture) if @architecture end @project.refresh! @applied = true self end |
#empty? ⇒ Boolean
22 |
# File 'lib/mxrb/semantic/renamer.rb', line 22 def empty? = @changes.empty? |