Class: Mxrb::Semantic::InlinePlan

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/semantic/inliner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project:, source:, called_name:, call_id:, inner_objects:, inner_flows:, entry_flow:, exit_flow:, source_doc:, source_raw:) ⇒ InlinePlan

Returns a new instance of InlinePlan.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mxrb/semantic/inliner.rb', line 11

def initialize(project:, source:, called_name:, call_id:,
               inner_objects:, inner_flows:,
               entry_flow:, exit_flow:,
               source_doc:, source_raw:)
  @project = project
  @source = source
  @called_name = called_name
  @call_id = call_id
  @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

#call_idObject (readonly)

Returns the value of attribute call_id.



9
10
11
# File 'lib/mxrb/semantic/inliner.rb', line 9

def call_id
  @call_id
end

#called_nameObject (readonly)

Returns the value of attribute called_name.



9
10
11
# File 'lib/mxrb/semantic/inliner.rb', line 9

def called_name
  @called_name
end

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/mxrb/semantic/inliner.rb', line 9

def source
  @source
end

Instance Method Details

#applied?Boolean

Returns:

  • (Boolean)


28
# File 'lib/mxrb/semantic/inliner.rb', line 28

def applied? = @applied

#apply!Object

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
# File 'lib/mxrb/semantic/inliner.rb', line 39

def apply!
  raise ArgumentError, "inline plan was already applied" if applied?

  @project.mpr.transaction { patch_source_microflow! }
  @project.refresh!
  @applied = true
  self
end

#changesObject



30
31
32
33
34
35
36
37
# File 'lib/mxrb/semantic/inliner.rb', line 30

def changes
  count = @inner_objects.size
  suffix = count == 1 ? "y" : "ies"
  [
    "inline #{@called_name} into #{@source.qualified_name}",
    "replace call_microflow activity with #{count} inlined activit#{suffix}"
  ]
end