Class: Mxrb::Semantic::RemovalPlan
- Inherits:
-
Object
- Object
- Mxrb::Semantic::RemovalPlan
- Defined in:
- lib/mxrb/semantic/remover.rb
Instance Attribute Summary collapse
-
#artifact ⇒ Object
readonly
Returns the value of attribute artifact.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#incoming ⇒ Object
readonly
Returns the value of attribute incoming.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply! ⇒ Object
-
#initialize(project:, artifact:, incoming:, children:) ⇒ RemovalPlan
constructor
A new instance of RemovalPlan.
- #safe? ⇒ Boolean
Constructor Details
#initialize(project:, artifact:, incoming:, children:) ⇒ RemovalPlan
Returns a new instance of RemovalPlan.
8 9 10 11 12 13 14 |
# File 'lib/mxrb/semantic/remover.rb', line 8 def initialize(project:, artifact:, incoming:, children:) @project = project @artifact = artifact @incoming = incoming.freeze @children = children.freeze @applied = false end |
Instance Attribute Details
#artifact ⇒ Object (readonly)
Returns the value of attribute artifact.
6 7 8 |
# File 'lib/mxrb/semantic/remover.rb', line 6 def artifact @artifact end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/mxrb/semantic/remover.rb', line 6 def children @children end |
#incoming ⇒ Object (readonly)
Returns the value of attribute incoming.
6 7 8 |
# File 'lib/mxrb/semantic/remover.rb', line 6 def incoming @incoming end |
Instance Method Details
#applied? ⇒ Boolean
17 |
# File 'lib/mxrb/semantic/remover.rb', line 17 def applied? = @applied |
#apply! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mxrb/semantic/remover.rb', line 19 def apply! raise ArgumentError, "removal plan was already applied" if applied? unless safe? raise ArgumentError, "cannot remove #{artifact.qualified_name}: " \ "#{incoming.size} incoming reference(s), #{children.size} child unit(s)" end @project.mpr.transaction { @project.mpr.delete_unit(artifact.unit_id) } @project.refresh! @applied = true self end |
#safe? ⇒ Boolean
16 |
# File 'lib/mxrb/semantic/remover.rb', line 16 def safe? = incoming.empty? && children.empty? |