Class: Mxrb::Model::Page

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

Overview

$Type: Pages$Page / Forms$Page 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

#allowed_module_rolesObject (readonly)

Returns the value of attribute allowed_module_roles.



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

def allowed_module_roles
  @allowed_module_roles
end

#data_sourceObject (readonly)

Returns the value of attribute data_source.



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

def data_source
  @data_source
end

#documentationObject (readonly)

Returns the value of attribute documentation.



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

def documentation
  @documentation
end

#excludedObject (readonly)

Returns the value of attribute excluded.



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

def excluded
  @excluded
end

#export_levelObject (readonly)

Returns the value of attribute export_level.



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

def export_level
  @export_level
end

#layout_idObject (readonly)

Returns the value of attribute layout_id.



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

def layout_id
  @layout_id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

Returns the value of attribute popup_height.



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

def popup_height
  @popup_height
end

Returns the value of attribute popup_resizable.



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

def popup_resizable
  @popup_resizable
end

Returns the value of attribute popup_width.



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

def popup_width
  @popup_width
end

#raw_documentObject (readonly)

Returns the value of attribute raw_document.



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

def raw_document
  @raw_document
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#widgetsObject (readonly)

Returns the value of attribute widgets.



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

def widgets
  @widgets
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
# File 'lib/mxrb/model/page.rb', line 15

def decode(doc)
  @raw_document        = doc
  @storage_type        = doc["$Type"] || "Forms$Page"
  @name                = doc["Name"] || doc["name"]
  @documentation       = doc["Documentation"] || doc["documentation"] || ""
  @url                 = doc["Url"] || doc["URL"] || doc["url"] || ""
  @title               = extract_text(doc["Title"] || doc["title"])
  @layout_id           = extract_layout(doc)
  @popup_width         = doc["PopupWidth"] || 0
  @popup_height        = doc["PopupHeight"] || 0
  @popup_resizable     = doc["PopupResizable"] == true
  @excluded            = doc["Excluded"] == true
  @export_level        = doc["ExportLevel"] || "Hidden"
  @allowed_module_roles = parse_array(doc["AllowedModuleRoles"] || doc["AllowedRoles"] || doc["allowedModuleRoles"])
  @parameters          = parse_array(doc["Parameters"] || doc["parameters"])
  @widgets             = []
  parse_widgets(widget_roots(doc))
end

#inspectObject



54
55
56
# File 'lib/mxrb/model/page.rb', line 54

def inspect
  "#<Mxrb::Page name=#{@name.inspect} layout=#{@layout_id.to_s.slice(0, 8)}>"
end

#to_bsonObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mxrb/model/page.rb', line 34

def to_bson
  {
    "$ID"                => @id,
    "$Type"              => @storage_type,
    "Name"               => @name,
    "Documentation"      => @documentation || "",
    "Url"                => @url || "",
    "Title"              => serialize_title,
    "Layout"             => @layout_id,
    "MarkAsUsed"         => false,
    "Excluded"           => @excluded || false,
    "AllowedModuleRoles" => IO::BsonCodec.build_array(@allowed_module_roles || [], marker: 1),
    "Parameters"         => IO::BsonCodec.build_array(@parameters || []),
    "PopupWidth"         => @popup_width || 0,
    "PopupHeight"        => @popup_height || 0,
    "PopupResizable"     => @popup_resizable || false,
    "ExportLevel"        => @export_level || "Hidden",
  }
end