Class: Mxrb::Model::Module
- Inherits:
-
Unit
- Object
- Unit
- Mxrb::Model::Module
show all
- Defined in:
- lib/mxrb/model/module.rb
Overview
$Type: Projects$Module
ContainmentName: "Modules"
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!
Instance Attribute Details
#app_store_guid ⇒ Object
Returns the value of attribute app_store_guid.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def app_store_guid
@app_store_guid
end
|
#app_store_version ⇒ Object
Returns the value of attribute app_store_version.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def app_store_version
@app_store_version
end
|
#export_level ⇒ Object
Returns the value of attribute export_level.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def export_level
@export_level
end
|
#from_app_store ⇒ Object
Returns the value of attribute from_app_store.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def from_app_store
@from_app_store
end
|
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def name
@name
end
|
#sort_index ⇒ Object
Returns the value of attribute sort_index.
10
11
12
|
# File 'lib/mxrb/model/module.rb', line 10
def sort_index
@sort_index
end
|
Instance Method Details
#associations ⇒ Object
43
|
# File 'lib/mxrb/model/module.rb', line 43
def associations = domain_model&.associations || []
|
#constants ⇒ Object
75
76
77
78
79
|
# File 'lib/mxrb/model/module.rb', line 75
def constants
@constants ||= document_units
.select { |u| u[:type] == "Constants$Constant" }
.map { unit_to_doc(_1) }
end
|
#decode(doc) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/mxrb/model/module.rb', line 13
def decode(doc)
@name = doc["Name"]
@sort_index = doc["SortIndex"] || doc["NewSortIndex"]
@from_app_store = doc["FromAppStore"] == true
@app_store_guid = doc["AppStoreGuid"]
@app_store_version = doc["AppStoreVersion"]
@export_level = doc["ExportLevel"] || "Hidden"
end
|
#domain_model ⇒ Object
── Children (resolved from Unit table by ContainerID) ────────────
35
36
37
38
39
40
|
# File 'lib/mxrb/model/module.rb', line 35
def domain_model
@domain_model ||= begin
raws = @mpr.units_by_containment("DomainModel").select { _1["ContainerID"] == @id }
raws.empty? ? nil : DomainModel.new(raws.first, @mpr)
end
end
|
#entities ⇒ Object
42
|
# File 'lib/mxrb/model/module.rb', line 42
def entities = domain_model&.entities || []
|
#enumerations ⇒ Object
69
70
71
72
73
|
# File 'lib/mxrb/model/module.rb', line 69
def enumerations
@enumerations ||= document_units
.select { |u| u[:type] == "Enumerations$Enumeration" }
.map { unit_to_doc(_1) }
end
|
#inspect ⇒ Object
101
102
103
104
|
# File 'lib/mxrb/model/module.rb', line 101
def inspect
"#<Mxrb::Module name=#{@name.inspect} entities=#{entities.size} " \
"pages=#{pages.size} microflows=#{microflows.size}>"
end
|
63
64
65
66
67
|
# File 'lib/mxrb/model/module.rb', line 63
def
@menus ||= document_units
.select { |u| u[:type] == "Menus$MenuDocument" }
.map { Menu.new(_1[:raw], @mpr) }
end
|
#microflows ⇒ Object
51
52
53
54
55
|
# File 'lib/mxrb/model/module.rb', line 51
def microflows
@microflows ||= document_units
.select { |u| u[:type] == "Microflows$Microflow" }
.map { Microflow.new(_1[:raw], @mpr) }
end
|
#module_roles ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/mxrb/model/module.rb', line 87
def module_roles
@module_roles ||= begin
raw = @mpr.children_of(@id).find { _1["ContainmentName"] == "ModuleSecurity" }
if raw
doc = @mpr.parse_contents(raw)
parse_array(doc["ModuleRoles"]).map do |role|
{ name: role["Name"], description: role["Description"].to_s }
end
else
[]
end
end
end
|
#nanoflows ⇒ Object
57
58
59
60
61
|
# File 'lib/mxrb/model/module.rb', line 57
def nanoflows
@nanoflows ||= document_units
.select { |u| u[:type] == "Microflows$Nanoflow" }
.map { Microflow.new(_1[:raw], @mpr) }
end
|
#pages ⇒ Object
45
46
47
48
49
|
# File 'lib/mxrb/model/module.rb', line 45
def pages
@pages ||= document_units
.select { |u| %w[Pages$Page Forms$Page].include?(u[:type]) }
.map { Page.new(_1[:raw], @mpr) }
end
|
#scheduled_events ⇒ Object
81
82
83
84
85
|
# File 'lib/mxrb/model/module.rb', line 81
def scheduled_events
@scheduled_events ||= document_units
.select { |u| u[:type] == "ScheduledEvents$ScheduledEvent" }
.map { unit_to_doc(_1) }
end
|
#to_bson ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/mxrb/model/module.rb', line 22
def to_bson
{
"$ID" => @id,
"$Type" => "Projects$Module",
"Name" => @name,
"SortIndex" => @sort_index || 0,
"FromAppStore" => @from_app_store || false,
"ExportLevel" => @export_level || "Hidden",
}
end
|