Class: Mxrb::Model::Microflow

Inherits:
Unit
  • Object
show all
Defined in:
lib/mxrb/model/microflow.rb

Overview

$Type: Microflows$Microflow ContainmentName: "Documents"

Instance Attribute Summary collapse

Attributes inherited from Unit

#bson_type, #container_id, #containment_name, #id, #mpr

Instance Method Summary collapse

Methods inherited from Unit

#initialize, #save!

Constructor Details

This class inherits a constructor from Mxrb::Model::Unit

Instance Attribute Details

#allow_concurrent_executionObject (readonly)

Returns the value of attribute allow_concurrent_execution.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def allow_concurrent_execution
  @allow_concurrent_execution
end

#allowed_module_rolesObject (readonly)

Returns the value of attribute allowed_module_roles.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def allowed_module_roles
  @allowed_module_roles
end

#documentationObject (readonly)

Returns the value of attribute documentation.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def documentation
  @documentation
end

#excludedObject (readonly)

Returns the value of attribute excluded.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def excluded
  @excluded
end

#flowsObject (readonly)

Returns the value of attribute flows.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def flows
  @flows
end

#mark_as_usedObject (readonly)

Returns the value of attribute mark_as_used.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def mark_as_used
  @mark_as_used
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def name
  @name
end

#objectsObject (readonly)

Returns the value of attribute objects.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def objects
  @objects
end

#parametersObject (readonly)

Returns the value of attribute parameters.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def parameters
  @parameters
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def return_type
  @return_type
end

#return_variable_nameObject (readonly)

Returns the value of attribute return_variable_name.



10
11
12
# File 'lib/mxrb/model/microflow.rb', line 10

def return_variable_name
  @return_variable_name
end

Instance Method Details

#decode(doc) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mxrb/model/microflow.rb', line 15

def decode(doc)
  @name                       = doc["Name"] || doc["name"]
  @documentation              = doc["Documentation"] || doc["documentation"] || ""
  @return_variable_name       = doc["ReturnVariableName"] || "ReturnValue"
  @allow_concurrent_execution = doc["AllowConcurrentExecution"] != false
  @mark_as_used               = doc["MarkAsUsed"] == true
  @excluded                   = doc["Excluded"] == true
  @allowed_module_roles       = parse_array(doc["AllowedModuleRoles"])
  @parameters                 = extract_parameters(doc)
  return_doc                  = doc["MicroflowReturnType"] || doc["ReturnType"]
  @return_type                = return_doc.is_a?(Hash) ? (return_doc["$Type"] || return_doc["Type"]) : return_doc

  obj_col = doc["ObjectCollection"] || {}
  @objects = parse_array(obj_col["Objects"] || obj_col["objects"] || obj_col)
  # Mendix stores all sequence flows (including flows inside looped
  # activities) at document level. Older MXRB-generated documents used
  # ObjectCollection/Flows, so keep that as a compatibility fallback.
  @flows   = parse_array(
    doc["Flows"] || doc["flows"] ||
    obj_col["Flows"] || obj_col["flows"] || []
  )
end

#inspectObject



56
57
58
# File 'lib/mxrb/model/microflow.rb', line 56

def inspect
  "#<Mxrb::Microflow name=#{@name.inspect} objects=#{@objects.size} flows=#{@flows.size}>"
end

#to_bsonObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mxrb/model/microflow.rb', line 38

def to_bson
  {
    "$ID"                       => @id,
    "$Type"                     => "Microflows$Microflow",
    "Name"                      => @name,
    "Documentation"             => @documentation || "",
    "ReturnVariableName"        => @return_variable_name || "ReturnValue",
    "AllowConcurrentExecution"  => @allow_concurrent_execution != false,
    "MarkAsUsed"                => @mark_as_used || false,
    "Excluded"                  => @excluded || false,
    "AllowedModuleRoles"        => IO::BsonCodec.build_array(@allowed_module_roles || [], marker: 1),
    "MicroflowParameterCollection" => serialize_parameters,
    "MicroflowReturnType"       => @return_type || default_void_return,
    "ObjectCollection"          => serialize_object_collection,
    "Flows"                     => IO::BsonCodec.build_array(@flows || []),
  }
end