Class: Mxrb::Semantic::ExtractionPlan
- Inherits:
-
Object
- Object
- Mxrb::Semantic::ExtractionPlan
- Defined in:
- lib/mxrb/semantic/extractor.rb
Overview
Plan produced by Extractor#plan. Describes what will be extracted and applies the change atomically when apply! is called.
Instance Attribute Summary collapse
-
#new_name ⇒ Object
readonly
Returns the value of attribute new_name.
-
#selected_ids ⇒ Object
readonly
Returns the value of attribute selected_ids.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply! ⇒ Object
- #changes ⇒ Object
-
#initialize(project:, source:, new_name:, selected_ids:, inner_objects:, inner_flows:, entry_flow:, exit_flow:, source_doc:, source_raw:) ⇒ ExtractionPlan
constructor
A new instance of ExtractionPlan.
Constructor Details
#initialize(project:, source:, new_name:, selected_ids:, inner_objects:, inner_flows:, entry_flow:, exit_flow:, source_doc:, source_raw:) ⇒ ExtractionPlan
Returns a new instance of ExtractionPlan.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mxrb/semantic/extractor.rb', line 13 def initialize(project:, source:, new_name:, selected_ids:, inner_objects:, inner_flows:, entry_flow:, exit_flow:, source_doc:, source_raw:) @project = project @source = source @new_name = new_name @selected_ids = selected_ids @inner_objects = inner_objects @inner_flows = inner_flows @entry_flow = entry_flow @exit_flow = exit_flow @source_doc = source_doc @source_raw = source_raw @applied = false end |
Instance Attribute Details
#new_name ⇒ Object (readonly)
Returns the value of attribute new_name.
11 12 13 |
# File 'lib/mxrb/semantic/extractor.rb', line 11 def new_name @new_name end |
#selected_ids ⇒ Object (readonly)
Returns the value of attribute selected_ids.
11 12 13 |
# File 'lib/mxrb/semantic/extractor.rb', line 11 def selected_ids @selected_ids end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/mxrb/semantic/extractor.rb', line 11 def source @source end |
Instance Method Details
#applied? ⇒ Boolean
30 |
# File 'lib/mxrb/semantic/extractor.rb', line 30 def applied? = @applied |
#apply! ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mxrb/semantic/extractor.rb', line 40 def apply! raise ArgumentError, "extraction plan was already applied" if applied? module_unit_id = find_module_unit_id @project.mpr.transaction do insert_extracted_microflow!(module_unit_id) patch_source_microflow! end @project.refresh! @applied = true self end |
#changes ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/mxrb/semantic/extractor.rb', line 32 def changes [ "extract #{@inner_objects.size} activit#{@inner_objects.size == 1 ? 'y' : 'ies'} " \ "from #{@source.qualified_name} into #{@new_name}", "replace selection in #{@source.qualified_name} with call to #{@new_name}" ] end |