Class: Mxrb::Semantic::Remover
- Inherits:
-
Object
- Object
- Mxrb::Semantic::Remover
- Defined in:
- lib/mxrb/semantic/remover.rb
Constant Summary collapse
- EMBEDDED_KINDS =
%i[module entity attribute association].freeze
Instance Method Summary collapse
-
#initialize(project) ⇒ Remover
constructor
A new instance of Remover.
- #plan(name) ⇒ Object
Constructor Details
#initialize(project) ⇒ Remover
Returns a new instance of Remover.
37 38 39 |
# File 'lib/mxrb/semantic/remover.rb', line 37 def initialize(project) @project = project end |
Instance Method Details
#plan(name) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mxrb/semantic/remover.rb', line 41 def plan(name) artifact = resolve(name) if EMBEDDED_KINDS.include?(artifact.kind) raise ArgumentError, "#{artifact.kind} removal requires a typed domain-model mutation" end raw = @project.raw_unit(artifact.unit_id) raise ArgumentError, "#{artifact.qualified_name} is not a removable unit" unless raw incoming = @project.references_to(artifact) .reject { _1.source.id == artifact.id } children = @project.children_of(artifact.unit_id) RemovalPlan.new(project: @project, artifact:, incoming:, children:) end |